How would I compile the x264 library for the i386 architecture? Usually to force an architecture I would use the follow command:
./configure CC="gcc -arch i386" CXX="g++ -ar开发者_如何学运维ch i386"
But it doesn't seem to work for x264.
To compile x264 I configure it and make it, this produces an x86_64 library. When I attempt to use the above command to force the i386 architecture I receive the following message:
Unknown option CC=gcc -arch i386, ignored Unknown option CXX=g++ -arch i386, ignored
The configure script then prints that it is configured for the X86_64 platform. I want to see it configured for the i386 platform and to produce an i386 binary.
Autotooled configure
scripts have special command-line arguments --build
and --host
that they use to configure cross-compilation. Some old configure scripts attempt to figure out they are cross-compiling by inspecting the output of the compiler, but telling the configure script explicitly is much saner and more robust.
See here, for example. Or this question.
(Oh, and the immediate reason for the "Unknown option" errors you're seeing is that environment-variable overrides go before the name of the script on the sh command line, not after it. It's not make
, where variable definitions can be given on the make command line itself.)
After reading the configure script and config.sub file, I found the following to work for building a i386 version of libx264:
./configure --host=i386-apple-darwin
I also encountered that "no working C Compiler found" error at one point. I had set the LDFLAGS environment variable to something wrong. So make sure LDFLAGS and CFLAGS are empty (or good) before proceeding.
export CFLAGS=""
export LDFLAGS=""
If you have an x86-64 gcc you can supply the "-m32" to ask it to compile a 32-bit binary. So you should be able to use configure like this:
./configure CFLAGS="-m32"
If however that doesn't work it may be a bug in the autotooling and the CFLAGS are getting overwritten. An alternative you can try:
make CFLAGS="-m32"
The problem with the latter is that you have to remember to do this, otherwise you'll end up with linking issues with some object files built for different architectures.
As per Apple's recommendations at http://developer.apple.com/library/mac/#documentation/Porting/Conceptual/PortingUnix/compiling/compiling.html try:
./configure
make CFLAGS="-arch i386" LDFLAGS="-arch i386"
If that doesn't work add the -isysroot flags as well (but 10.6 or 10.7 rather than 10.4u)
精彩评论