Linux – How to compile 64-bit file linking with 32-bit library

32-bit64-bitlinux

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!

Best Answer

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.

Related Topic