Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile program for 32bit on 64bit Linux OS causes fatal error

Tags:

c++

c

linux

ubuntu

Using

gcc -m32 myprog.c 

should compile in 32 bit version the file myprog.c.

Unfortunately I get this error:

In file included from /usr/include/stdio.h:27:0,                  from myprog.c:1: /usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory #include <sys/cdefs.h> 

How could I fix this?

If I don't use -m32 it works but uses 64 bit instructions.

like image 611
AndreaF Avatar asked May 06 '14 14:05

AndreaF


1 Answers

To compile 32 bit binaries on 64 bit Linux version, you have to Install libx32gcc development package and 32 bit GNU C Library

try this

sudo apt-get install libx32gcc-4.8-dev 

and

sudo apt-get install libc6-dev-i386 
like image 195
Silverstorm Avatar answered Sep 22 '22 11:09

Silverstorm