Reputation: 93
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!
Upvotes: 1
Views: 8977
Reputation: 341
suppose you compiled a 32 bit version of your program (let's call it foo.c ) in the following manner :
gcc -m32 -c foo.c -o foo.o
You should then call the linker on it using the -melf_i386 flag.
ld <whatever commands / flags you gave earlier> -melf_i386
Example :
ld -o foo.bin --oformat binary basic.o -melf_i386
Upvotes: -1
Reputation: 34563
You can't mix 32-bit and 64-bit code in the same program. The compiler is telling you that one of your .o
files is compiled as a 64-bit object, so it can't be linked into a 32-bit executable. You'll need to recompile that object file, and probably others as well, from source code using -m32
for everything.
Upvotes: 8