Compiling 32 bit programs on 64 bit system

I’m using a chroot environment to compile my program for 32 bit environments. Using chroot environment through schroot is easy but is there a way to make compiling without using chroot?

Yes, you can use -m32 option of gcc

In order to be able to compile with -m32 option, you need multilib gcc and libc6 development package for i386 platform.

You can install with in Debian based systems like that:

sudo apt-get install libc6-i386 gcc-multilib

If you want make same on c++, you have to install similar packages for c++ environment like that:

sudo apt-get install g++-multilib lib32stdc++-4.9-dev

After that you can compile programs with:

gcc -m32 -o myprog myprog.c