Trying to compile even the simplest (int main(){}) program with -m32 on a 64-bit system fails:

$ gcc -m32 test.c
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/ when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

It seems to be still erroneously searching in the wrong directories when -m32 is specified.

libgcc-4.8-dev:i386 is installed and I've verified that the 32-bit libraries are located in /usr/lib/gcc/i686-linux-gnu/4.8/.

I've tried setting and exporting LD_INCLUDE_PATH and LD_LIBRARY_PATH to no avail.

up vote 19 down vote accepted

First, you need to install "gcc-multilib" and "g++-multilib"

sudo apt-get install gcc-multilib g++-multilib

Then your current command will work,

$ cat hello.c
#include <stdio.h>

int main(int argc, char *argv[]) {
    puts("Hello, World!");
$ uname -a
Linux vbox-1404 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ gcc -m32 hello.c
$ ./a.out
Hello, World!
$ file a.out
a.out: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=80bdc95e2941e3ba8d7bb7c1682098f20e77cebc, not stripped
  • 1
    That did it, thanks! – Vladimir Panteleev Apr 23 '14 at 14:01
  • 2
    Note: For C++ programs, g++-multilib will also be required. – Vladimir Panteleev Jun 28 '14 at 12:32
  • Consider also: libc6-dev-i386. – kenorb Jun 14 '15 at 11:47

For successfully compiling C code to x86 32 Bit executables in an x86_64 environment you have to install the following extra packages:

sudo apt-get install libc6-dev-i386 gcc-multilib

After a compile call like

$ gcc -m32 test.c -o test


Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.