Problem with compiling using -m32

Ian Lance Taylor iant@google.com
Fri Feb 11 06:52:00 GMT 2011


Alireza Haghdoost <haghdoost@gmail.com> writes:

> I am trying to make an application on a 64-bit machine with -m32
> option. I have add "-m32" in CFLAGS and
> "-L/usr/lib/gcc/x86_64-linux-gnu/4.4/32 -m32 -L/usr/lib32" in LDFLAGS.
> However I have got the following error :
>
>
> cc -m32 -g -I../../diskmodel/include -I../../libparam/include
> -I../../libddbg/include   -c -o driver.o driver.c
> cc -m32 -g -I../../diskmodel/include -I../../libparam/include
> -I../../libddbg/include -o layout_simple layout_simple.c driver.o
> -L../../diskmodel/lib -ldiskmodel -L../../libparam/lib -lparam
> -L../../libddbg/lib -lddbg -L/usr/lib/gcc/x86_64-linux-gnu/4.4/32 -m32
> -L/usr/lib32
> /usr/bin/ld: i386:x86-64 architecture of input file
> `/usr/lib/gcc/x86_64-linux-gnu/4.1.3/crtbegin.o' is incompatible with
> i386 output
> /usr/bin/ld: i386:x86-64 architecture of input file
> `/usr/lib/gcc/x86_64-linux-gnu/4.1.3/crtend.o' is incompatible with
> i386 output
> collect2: ld returned 1 exit status
> make: *** [layout_simple] Error 1
>
>
> I have 32-bit version of crtbegin.o and crtend.o in
> /usr/lib/gcc/x86_64-linux-gnu/4.4/32/ However gcc try to use 64-bit
> version from /usr/lib/gcc/x86_64-linux-gnu/4.1.3/.
>
> Does any one know how I can force gcc to use object files in
> /usr/lib/gcc/x86_64-linux-gnu/4.4/32/ ?

I note that the version numbers in those pathnames are different.
Presumably the "cc" command is gcc version 4.1.3.  If you want to use
the crtbegin.o and crtend.o in the 4.4 directory, you should be running
gcc 4.4.  There are things you could do the work around this, but mixing
different versions will most likely just get you into trouble.

Ian



More information about the Gcc-help mailing list