Create a 32-bit version on 64-bit Linux using automake configure script?

I use a 64-bit system, but I want a set of 32-bit binaries. What parameters should be passed to the script configurator to create a 32bit / x86 configuration file?

+47
autotools automake configure
Jul 16 '10 at 4:22
source share
5 answers

Passing the next argument to configure the script allowed me to create a 32-bit library on 64-bit Linux

./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" 
+56
Jul 25 '10 at 4:46
source share

Jack's answer is not complete.

You need compiler support / libc for 32-bit compilation. On some distributions, such as Ubuntu, you need to install the gcc-multilib and / or g++-multilib :

 sudo apt-get install gcc-multilib g++-multilib 

Then you can invoke configure, as you said, to specify a 32-bit host and pass 32-bit flag flag compilations:

 ./configure --host=i686-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" 

If you do not have multilib installed, you will receive an error message, for example configure: error: C compiler cannot create executables when passing the -m32 flag.

+38
Jul 19 '13 at 14:03
source share

I did better by installing my own compiler instead. Thus, all configure tests, even those using custom CFLAGS, worked correctly:

 ./configure CC="gcc -m32" CXX="g++ -m32" 

You still need the 32-bit versions of all the libraries that the application uses, so any errors regarding the missing libraries are 32-bit.

+6
Feb 20 '15 at 22:52
source share

Assuming gcc / g ++:

 CPPFLAGS=-m32 ./configure ... 
+3
Jul 16 '10 at 4:33
source share

An alternative way to do the above would be (if any) to use a dedicated x86 compiler. Then the configuration line will look like this (I called x86-tools after the template "<toolname> -x86"):

 CC="/path/to/c/compiler/gcc-x86" CXX="path/to/cpp/compiler/g++-x86" LD="path/to/linker/ld-x86" ./configure 
+1
Jul 11 '15 at 16:07
source share



All Articles