Build 32bit on 64 bit Linux using an automake configure script?
Assuming gcc/g++:
CPPFLAGS=-m32 ./configure ...
Jack's answer is incomplete.
You need compiler/libc support for 32-bit compilation. In some distros like Ubuntu, what you need to do is install packages gcc-multilib
and/or g++-multilib
:
sudo apt-get install gcc-multilib g++-multilib
Then you can call configure as you said, specifyiong a 32-bit host and passing 32-bit compilation flags:
./configure --host=i686-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"
If you do not have multilib installed, you will get an error like configure: error: C compiler cannot create executables
when passing the -m32
flag.
I had better success by setting a custom compiler instead. This way all the configure tests, even the ones using custom CFLAGS, worked correctly:
./configure CC="gcc -m32" CXX="g++ -m32"
You still need 32-bit versions of all the libraries the application uses of course, so any errors about missing libraries are referring to the 32-bit ones.
Passing the following argument to configure script allowed me to build the 32bit library on 64bit Linux
./configure --build=i686-pc-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32