0

My system is Centos 5.8 64-bit, and I want to compile a file linking with 32-bit library. I add -m32 while compiling, but the result shows "i386:x86-64 architecture of input file `gc_basic_call_model_voice_video_3g_cnf_nbup.o' is incompatible with i386 output". It seems that the file can't be compiled on 32-bit. But if I don't add -m32, the library can't be compiled. How to compile the file successfully, thanks!

4

2 回答 2

7

您不能在同一个程序中混合使用 32 位和 64 位代码。编译器告诉您,您的.o文件之一被编译为 64 位对象,因此无法链接到 32 位可执行文件。您需要从用于所有内容的源代码重新编译该目标文件,可能还有其他文件-m32

于 2012-04-09T05:19:19.053 回答
-1

假设您以下列方式编译了程序的 32 位版本(我们称之为 foo.c):

gcc -m32 -c foo.c -o foo.o

然后,您应该使用 -melf_i386 标志在其上调用链接器。

ld <whatever commands / flags you gave earlier> -melf_i386

例子 :

ld -o foo.bin --oformat binary basic.o -melf_i386
于 2016-11-02T20:43:30.357 回答