Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass -m elf_i386 to gcc?

Tags:

gcc

ld

I wrote like this :

 gcc -m elf_i386

it says:

gcc: error: elf_i386: No such file or directory

basically I am trying to compile a 32bit program on 64bit system,but error :

/usr/lib64/gcc/x86_64-suse-linux/4.6/../../../../x86_64-suse-linux/bin/ld: 
skipping incompatible /usr/lib/libSDL.so when searching for -lSDL

which I've checked the project built with -m32 and I can see all the *.o file are ELF 32-bit LSB,and the /usr/lib/libSDL.so are ELF 32-bit LSB too...so I might need pass -m elf_i386 to ld right? but I don't use ld directly I just use gcc to compile it.

like image 509
user1051003 Avatar asked Jul 31 '12 21:07

user1051003


1 Answers

gcc -m32

is what you want probably. The elf_i386 is passed by gcc to ld (if needed) just as Alan Curry mentioned in the comments.

The "skipping incompatible library" warning is just a warning and if it doesn't come up with "can't find the library", then you can assume it linked to the correct binary (because of the -m32 option).

like image 163
Johann Avatar answered Oct 05 '22 00:10

Johann