32

I'm trying to compile a c program as a 32 bit binary instead of 64 bit. I started by just adding -m32 and got some errors. Googling around a little I came across a note to install ia32-libs. Running apt-get install ia32-libs resulted in a notification taht it was already installed and at the newest version.

There is a chain of libraries each one including the next until it fails:

/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory

It seems to be including 32 bit versions of the other includes /usr/include/c++/4.6/x86_64-linux-gnu/32/bits/ ...

What am I missing?

Matt
  • 527

3 Answers3

73

Lekensteyn's answer conflicted with lots of existing packages for me (on 64-bit oneiric).

I instead did this, which pulled in the libc6-dev-i386 package:

sudo apt-get install gcc-multilib
vvvvv
  • 878
A B
  • 1,466
7

ia32-libs just contains some compatibility libraries haven't been migrated yet to Multi Arch. For compiling 32-bit libraries, you need to install the 32-bit libraries and development files for C:

sudo apt-get install libc6-dev:i386

See also: Does the multiarch feature in 11.10 mean the death of force--architecture installs?

Lekensteyn
  • 178,446
0

For those from future, this is a ten-year old question. Sadly none of the above solutions work for me.

Here is a similar but rather new one How to compile 32-bit executable on 64 bit system, and the solution of this fresh post does solve my problem.

Just install this:

sudo apt install libc6-dev-i386
Steve Lau
  • 101