Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 build the PHP memcache extension (v2.2.6) for i386 (32bit) on my x86_64 Ubuntu 11.04.

./configure uses config.guess by default (which outputs x86_64-unknown-linux-gnu on my system) but I want to override that.

How would I have to proceed?

share|improve this question
up vote 5 down vote accepted

You need two things to cross-compile: a compiler that can generate code for the target architecture, and the static libraries (*.a) for the target architecture. Install at least the libc6-dev-i386 Install libc6-dev-i386 packages, and possibly other lib32.*-dev packages. The libc6-dev-i386 also pulls in the components of gcc needed for cross-compilation in the gcc-multilib package Install gcc-multilib. Then tell gcc to compile for i386 by passing it the -m32 flag through the CFLAGS variable.

sudo apt-get install libc6-dev-i386 lib32ncurses5-dev … # whatever 32-bit libraries you need
export CFLAGS='-m32'
./configure …

If you don't find all the libraries you need, it'll probably be easier to install a 32-bit Ubuntu in a chroot. Ubuntu ships dchroot Install dchroot from the Debian buildd project, which makes running a chrooted system easy. Use debootstrap Install debootstrap to perform the installation. There's a reasonable-looking dchroot tutorial on the Ubuntu forums.

share|improve this answer
Hi,There was some issue in this images used in this answer!! Could you change it. – saravanakumar Jun 22 at 6:01
@saravanakumar Done. If you see links to bit.ly/software-small please update them to hostmar.co/software-small , unfortunately the old URL no longer works. meta.askubuntu.com/questions/548/… – Gilles Jun 22 at 7:04
Sure! Thanks @Giles – saravanakumar Jun 22 at 7:45

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.