How to Compile Glibc 32Bit on an X86_64 MAChine

How to compile glibc 32bit on an x86_64 machine

I edited the question, but then I realized the proper way is to add an answer. Here's what finally worked:

 $ ../../src/glibc-2.6/configure --prefix=$HOME/glibc32-2.6 \
--host=i686-linux-gnu \
--build=i686-linux-gnu \
CC="gcc -m32" CXX="g++ -m32" \
CFLAGS="-O2 -march=i686" \
CXXFLAGS="-O2 -march=i686"

I think putting -m32 in CC and CXX instead of CFLAGS and CXXFLAGS was important because there was at least one compile operation during the make which didn't use CFLAGS or CXXFLAGS, and -m32 absolutely has to always be there. Not sure why -march=i686 was necessary (given the -m32 parts and the --host/build options), but it was.

newlib: Compiler gets confused when building 32-bit compatibility

I fixed it. I simply disabled multilib, because I can just simply build another compiler for 32-bit.

Force gcc to compile 32 bit programs on 64 bit platform

You need to make GCC use the -m32 flag.

You could try writing a simple shell script to your $PATH and call it gcc (make sure you don't overwrite the original gcc, and make sure the new script comes earlier in $PATH, and that it uses the full path to GCC.

I think the code you need is just something like /bin/gcc -m32 $* depending on your shell (the $* is there to include all arguments, although it might be something else – very important!)

How to compile a 32-bit binary on a 64-bit linux machine with gcc/cmake


export CFLAGS=-m32

Build 32bit on 64 bit Linux using an automake configure script?

Passing the following argument to configure script allowed me to build the 32bit library on 64bit Linux

./configure --build=i686-pc-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32


Related Topics



Leave a reply



Submit