Build 32bit on 64 bit Linux using an automake configure script?

走远了吗. 提交于 2019-11-26 18:51:13

问题


I'm using a 64bit system but want a set of 32bit binaries. What options must I pass to a configure script to generate a 32bit/x86 makefile?


回答1:


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"



回答2:


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.




回答3:


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.




回答4:


Assuming gcc/g++:

CPPFLAGS=-m32 ./configure ...



回答5:


An alternative way to the things described above would be (if you have) to use a dedicated x86 compiler. The configure line would then be like this (I named the x86-tools after the pattern "<toolname>-x86"):

CC="/path/to/c/compiler/gcc-x86" CXX="path/to/cpp/compiler/g++-x86" LD="path/to/linker/ld-x86" ./configure


来源:https://stackoverflow.com/questions/3261909/build-32bit-on-64-bit-linux-using-an-automake-configure-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!