Steven W. Orr wrote:
On Tuesday, Nov 28th 2006 at 18:50 +0100, quoth Fernando Apesteguía:
=>I'm using FC6 for x86_64. I need to compile a program for linux 32
=>bits. I tried with the -m32 flag to gcc, but I got:
=>core_recv.c:(.text+0x130): undefined reference to `__umoddi3'
=>and tons of ld warnings:
=>/usr/bin/ld: warning: i386 architecture of input file `main.o' is
=>incompatible with i386:x86-64 output
=>I searched in Google, but couldn't find the solution. For the
=>undefinded references I suppose it is because some missing i386
=>And what about the other things? How can I compile a 32 bit
=>application under a 64 bit system?
Sorry, but you need to create a seperate cross compiler. You're running on
a your native system and you're trying to create an executable for another
machine. So you need a whole different toolchain. The easiest way *might*
be to use buildroot (just google it please) but the point is that you need
a whole different setup to target a different machine. gcc, binutils,
libc, gdb, the whole banana, and the whole thing has to be specific to the
version of the kernel you're running on the target system. Just don't even
*try* to figgah out options for your current system. It won't work.
Of course it will, we do it all the time. Gcc is perfectly capable of building
32bit and 64bit libraries and executables. All that's required is that the 32bit
development libraries are installed.
The OP has, by the looks of it, successfully created a 32bit main.o. The error
message indicates that the link stage attempted to link this 32bit object file
into a 64bit application. Something which won't work. The link stage also
requires the -m32 option to tell gcc/ld that a 32bit executable is to be
created, and that libraries in /usr/lib etc. should be used, rather than the
64bit libraries in /usr/lib64 etc.
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : [email protected]
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555