3
votes

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++ -arch 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.

4
Define "it doesn't seem to work".Oliver Charlesworth
What do you expect to happen? What do you see instead?Chris Jester-Young
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.user293895
Have you tried ./configure --help? x264 does not use plain autotools if I remember correctly.rubenvb
I have, it isn't helpful with regarding cross compiling, it says there is a --host parameter but I do not know the host I need to enter for i386user293895

4 Answers

5
votes

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.)

4
votes

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=""
2
votes

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.

0
votes

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)