A few words of thanks would be greatly appreciated.

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

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.

A few words of thanks would be greatly appreciated.

Ask a question
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Published by . Latest update on 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 (https://ccm.net/).

1 Comment