Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to compile a 32 bit version of python on a 64 bit ubuntu system with the following configure command:

CC="gcc -m32" LDFLAGS="-L/lib32 -L/usr/lib32 \ -Lpwd/lib32 -Wl,-rpath,/lib32 \
    -Wl,-rpath,/usr/lib32" \ ./configure --prefix=/opt/pym32

then make, make install. No errors, but it should be something wrong because a "readelf -h python" tells me that python was build as a ELF64 instead.

share|improve this question
you are "readelf'ing" the correct python - are you picking up the default 64bit python ? i.e. which python – fossfreedom Sep 5 '11 at 10:51
yep :( i used an absolutepath to readelf: readelf -h /opt/pym32/bin/python – Gabriele B Sep 5 '11 at 11:32
Is using chroot an option? – Nathan Osman Sep 5 '11 at 16:52
yes, actually it is...i was just wondering for a one-line solution – Gabriele B Sep 6 '11 at 10:39
Here is chroot instructions for chroot'ed Python:… – Mikko Ohtamaa Sep 10 '11 at 18:14
up vote 4 down vote accepted

Use "--build" and "--host".

./configure --help
System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

You need to use ./configure --build=x86_64-pc-linux-gnu --host=i686-pc-linux-gnu to compile for 32-bit Linux in a 64-bit Linux system. You still need to add the other ./configure options.

share|improve this answer
tnx a lot! it works perfectly :) – Gabriele B Nov 18 '11 at 8:13
"configure: error: readelf for the host is required for cross builds". Using "locate '*-readelf'" gives only "/usr/bin/x86_64-linux-gnu-readelf". I guess I need to find a package to install that includes i686-linux-gnu-readelf" ? – Jonathan Hartley Jan 8 at 2:30

If you want the compile to be debuged, you should post (in a pastebin) your verbose output from gcc. Otherwise, it's impossible to know.

The suggested solution of using chroot may help you and Mikko kindly offers a link to guide users in how to use chroot for 32bit python on a 64bit machine:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.