123

It has been weeks that I am trying to use Code::Blocks IDE on Ubuntu 14.04 LTS to program Atmega16, however I am hindered by the following error while compiling/building the program in C::B

/usr/include/features.h|374|fatal error: sys/cdefs.h: No such file or directory|

I have read this thread and based on that I have tried to purge libc6-dev and ran into trouble by removing the dependencies. From previous experience I knew that there is a huge probability to get into broken pipe error. I tackled it by installing the lost dependencies.

Now still I have the same error.

Mandar
  • 1,351
  • 2
  • 9
  • 7

8 Answers8

174

If you are on an amd64 installation, you can try to install the package libc6-dev-i386. This helped me solve the same issue you encountered while trying to compile smm from i8kutils.

zerwas
  • 3,883
  • 9
    This worked like a charm. This should be the accepted answer. – Patryk Jul 31 '14 at 12:47
  • 17
    Might be better to install gcc-multilib and g++-multilib. – RobotHumans Jul 18 '15 at 17:23
  • Installing libc6 and libc6-dev solved it for me. I had also found some reference for it, but sadly i lost it. – Mandar Nov 19 '15 at 14:33
  • 6
    libc6-dev-i386 is one of the additional packages will be installed if i run sudo apt-get install g++-multilib in Kali 2016.2. – 林果皞 Oct 12 '16 at 19:13
  • @RobotHumans, installing gcc-multilib wants to remove my gcc-5-arm-linux-gnueabi and doesn't seem to install anything actually replacing it. So that doesn't look like a good idea. Sorry. – Alexander Amelkin Nov 30 '17 at 11:07
  • 3
    If you have many compiler toolchains, that would seem like a packaging bug. The multilib one gets you 32 and 64 bit builders, but probably says something silly like remove all other toolchains first to try and prevent conflicts. Worked for me, but I did not have compilers for arm. I use VMs for that. – RobotHumans Nov 30 '17 at 13:43
52

On my machine, where I've probably screwed around too much with 32 and 64 bit architecture files, I resolved this issue by installing g++-multilib.

muru
  • 197,895
  • 55
  • 485
  • 740
Ted Hahn
  • 521
4

Typing the command:

sudo apt-get --reinstall install libc6 libc6-dev

solved the problem.

ololobus
  • 103
user845225
  • 41
  • 1
  • 1
    Hi and welcome to askubuntu! Please use the guideline of https://askubuntu.com/editing-help to format your posts. – abu_bua Jun 30 '18 at 09:05
  • Welcome to Ask Ubuntu! ;-) Could you please review my edits and also review the editing help to improve the readability of your answers in the future... ;-) (CC @abu_bua ) – Fabby Jun 30 '18 at 19:20
3

Looks like sys/cdefs.h is defined under /usr/include/x86_64-linux-gnu/sys, but /usr/include/x86_64-linux-gnu is NOT a default INCLUDE_PATH.

Pei JIA
  • 370
  • 2
  • 4
  • 12
3

I know this is an Ubuntu-centric branch of but this page is the first one that came up when I searched this error on Google (even when I put -Ubuntu in the search), so I'm going to share my answer for Arch linux here:

In Arch, I got a /lib/cpp fail sanity check because the package glibc was corrupt and missing all the /usr/include/sys headers. I resolved this error by recompling glibc.

thebunnyrules
  • 1,083
  • 1
  • 13
  • 20
  • 6
    Funny, I resolved this problem a couple of months ago and I completely forgot about it. So here I was looking for a solution again. Thank god for this site. :) – thebunnyrules Feb 21 '17 at 02:11
  • That comment :) I have heard that sites in Stack Exchange overall have done this plenty of times before – Paul Stelian May 25 '18 at 15:24
  • This was killing me, fresh install of Arch and I couldn't build anything. I check and /usr/include/sys is totally empty! Reinstalled glibc and everything is perfect. Thanks a billion. – Ryan Kozak Jul 07 '21 at 23:49
1

apt install gcc-multilib will also install the library you need libc6-dev-i386 along with packages you might need in future.

Machinexa
  • 111
0

I got this while trying to compile openssl-1.0.2a while chrooted to a wheezy 32-bit partition while running a 64-bit kernel. the "./config" script was too smart, and decided to configure for amd64. I solved it by MACHINE=i386 ./config --prefix=$HOME, and then make worked without error.

0

I got this by accidently adding the -m32 option (gcc told me to add for -maes but it was wrong).