GCC output 32 bit binary on 64 bit platform
I tried recently to compile a 32 bit older program that I wrote on a 64 bit Ubuntu Linux. The project compiles several assembly files with NASM, some other files with GCC and in the end linking everything together with GNU LD. On the first try I got the following error message:
ld: i386 architecture of input file `arch/monitor.o' is incompatible with i386:x86-64 output
After some goggling I found out how to force LD into linking the binaries for an i386 architecture by giving it the -m elf_i386 argument but after that it started complaining about the binaries outputted by GCC not being compatible with the i386 output.
ld: i386:x86-64 architecture of input file `kernel/main.o' is incompatible with i386 output
That is because on x86-64 GCC outputs 64 bit binaries. In order to tell GCC to output x86-32 binaries you have to use -m 32 flag. After this it worked perfectly!
No trackbacks yet.