Compiling/testing in 32-bit on Ubuntu X86-64

April 2018

If one has the need to devise a source code for either testing or using it in a form or a binary of the value 32-bit, a library of binary 32 bits is required in Ubuntu. Some packages in these operating systems have to be implemented in this case so that the command works. Install a multilib function to ensure that a library of binary 32 bits is available. After this is done, append -m32 to the code so that it works. Once these steps are followed in Ubuntu, one can use the program for standard functions. For using other libraries, it should be ensured that it's in sync with 32-bit.

If you want to compile a source code for testing purposes 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 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 compiled in 32-bit too.
Published by netty5. Latest update on March 17, 2012 at 10:25 AM by Virginia Parsons.
This document, titled "Compiling/testing in 32-bit on Ubuntu X86-64," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Having a static IP address under Ubuntu 8.10
Installing TrueType fonts under Ubuntu