日期:2014-05-16  浏览次数:20721 次

64位linux编译32位应用程序,怎样设置???
我在64位Linux上使用gcc编译32应用程序,这个应用程序依赖一个32位动态链接库,所以需要编译成32位应用程序,该系统上只有支持64位编译的gcc,但是存在32位的lib库,请问如何设置才能编译该应用程序。
命令:g++ -o test test.cpp -lmylib32
报错:libmylib32.so 不兼容
命令:g++ -m32 -o test test.cpp -lmylib32
报错:找不到-lgcc
命令:g++ -m32 -o test test.cpp -lmylib32 -L/usr/lib/gcc32
报错:/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib64/gcc/x86_64-rocky-linux-gnu/4.1.2/./crtbegin.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib64/gcc/x86_64-rocky-linux-gnu/4.1.2/./crtend.o' is incompatible with i386 output

怎样才能编译成功,尽量只是修改设置,不安装软件,因为发现安装软件总是报错。


------解决方案--------------------
很多发行版可以安装32位运行库的
ia32那些就是
然后你就可以用-m32编译了

如果发行版不提供,那么你只有自行交叉编译