Since Ubuntu 11.04 (natty) and Debian 7.0 (wheezy) introduced multiarch support, 32-bit and 64-bit libraries can coexist on one system. To install a 32-bit library libXX, first add the necessary 32bit architecture to your system:
sudo dpkg --add-architecture i386
sudo apt-get update
Then install the 32bit library:
sudo apt-get install libXX:i386
The ia32-libs package. As of Ubuntu 12.04 precise, it no longer contains any libraries, it only pulls in libXX:i386 packages as dependencies.
The compile part is rather easy for C and C++ programs, add -m32 to CFLAG or CXXFLAG, which will make generated program 32bit, e.g
export CFLAGS="-m32"
gcc main.c -o main
This works for makefile-based projects as well.