Compiling/testing in 32-bit on Ubuntu X86-64
If you want compile a source code for testing purpose or to use it as a 32-bit binary,the main problem is that the headers of the standard library are not suitable for this purpose and that a version of the standard library in 32 bits is needed. (specific gcc library compiled in 32 bits).
To install these packages, type this command:
sudo apt-get install gcc-multilib libc6-i386 lib6-dev-i386
To compile your program so we were just attach the-m32:
gcc -m32 test.c -o test
This will be enough for a simple program using only the standard library but for programs using other libraries,all these libraries must be compile in 32-bit too.