Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raspberry Pi -fatal error: sys/cdefs.h: No such file or directory

I'm trying to compile gcc5.3.0 on my Raspberry Pi with latest Raspbian system image.

$ ./configure --enbale-checking=release --enable-languages=c,c++,fortran --host=arm-cortexa7_neon-linux-gnueabihf --build=arm-cortexa7_neon-linux-gnueabihf --target=arm-cortexa7_neon-linux-gnueabihf
$ make

However, the original compiler (gcc4.9) complains about not founding sys/cdefs.h when compiling libgcc.

I checked I have libc6-dev and build-essential installed.

So I used grep -R 'cdefs' /usr/include/ to search it and I found it at /usr/include/bsd/. I created the sys directory and made hard links to these headers under /usr/include/bsd/sys.

This time it gave me a more weird error, /usr/include/stdio.h:312:8: error: unknown type name 'FILE'.

I searched this on stackoverflow, and there's a similar question, https://stackoverflow.com/a/21047237/5691005. But when I removed /usr/include/sys and /usr/include/bsd, then reinstalled libc6-dev, I cannot find sys/cdefs.h under /usr/include, and the compiler gave errors still.

I'm now totally lost. Any suggestion will be appreciated.

like image 476
0xBBC Avatar asked Mar 06 '16 02:03

0xBBC


1 Answers

I had similar problem with compiling gcc-8.2. I tried to do as described here with reinstalling:

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

After that I was locating all missing headers:

find / -name cdefs.h 

and copying them to /usr/include: those steps allowed only to move forward but I still didn't manage to completely build gcc.

The best solution I found is to download compiled version of gcc-8.1 from: https://solarianprogrammer.com/2017/12/07/raspberry-pi-raspbian-compiling-gcc/

like image 106
baziorek Avatar answered Oct 06 '22 05:10

baziorek