Originally published on the old depletionmode / 2of1 blog (archived copy).
Here are two easy ways to compile 32-bit binaries on a 64-bit system.
gcc compiler options
Just use the ‘-m32′ compiler option.
You will need to make sure that you have the gcc multilib package for your distro installed.
Also you need 32-bit versions of the libraries you wish to link against present in /usr/lib32.
chroot environment
Create a 32-bit chroot environment.
This can easily be done on Debian-based distros with debootstrap.
Here’s a nice guide for Ubuntu with a fantastic dchroot script for running ‘make32′ and ‘gcc32′ etc.