Reputation: 12395
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.
Upvotes: 41
Views: 52425
Reputation: 561
To fix the issue we first need to know which package will provide the file sys/cdefs.h
In CentOs/RHEL based system you can find it by running below command
yum provides '*sys/cdefs.h'
Similarly, in Debian/Ubuntu systems you can find it by running
apt-file search 'sys/cdefs.h'
Note: If apt-file package is not already present on the system install it with command
apt-get install apt-file
Both above commands will scan the respective package management systems database i.e RPM/Apt and tells the name of the package which supplies the file ending with "sys/cdefs.h".
Install the appropriate package from the packages listed by the commands.
Like
On CentOs/RHEL:
yum install glibc-headers
On Debian/Ubuntu
apt-get install libc6-dev
This approach is not only useful for this particular issue but any similar issue which is reporting some required file being provided by some package being not present.
Upvotes: 1
Reputation: 6568
I encountered to this same problem. when I was trying to build 32 bit so file while i'm in 64 bit ubuntu version.
you can build by switching your lib version into 64 bit in netbeans (-> project properties -> C compiler -> additional options) set to
-shared -m64
Upvotes: 1
Reputation: 879
You need gcc multilib support. Install the package gcc-multilib
. E.g.:
sudo apt-get install gcc-multilib
Upvotes: 13
Reputation: 15845
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
Upvotes: 81