I would like to build an application for i386 architecture but currently I'm running x86_64 OS and shared libraries which I use to link to generate application binaries are built for i386 architecture. If I run file command on shared libraries I use I get following output
ELF 32-bit LSB shared object, Intel 80386, version 1 (S│Size: 13064788 SV), dynamically linked, not stripped
But gcc skips this shared library saying it as incompatible one. So I was just wondering is there any option with which I can tell GCC to compile for i386 architecture rather than for my native machine architecture?
Yes I've gone through many cross compilation questions on this forums but I didn't fully understand the funda as I'm new to cross compilation stuffs. Does cross compilation requires me to have a gcc which is built for same architecture as the architecture for which I'm trying to compile? Is use of tool chains like binutils is mandatory for cross compilation?
I'm using a simple handwritten make file and not using any tool specific to开发者_StackOverflow社区ol chains.
Thanks in Advance
Actually, you might be able to get away with simply specifying "-m32" on your gcc build command. Try it :)
If you get link errors, then trying installing the 32-bit C runtime libraries; then retry your "gcc -m32" build:
sudo apt-get install ia32-libs
The -m32
option tells the compiler to generate 32-bit code instead of 64 bit. You might also want -march=i386
if you specifically want 80386 code (and optimization).
GCC supports the -m32
flag which makes it compile for a 32 bit platform.
精彩评论