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

2

6

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://mcmap.net/q/1917964/-c-compiler-error-from-standard-headers-undefined-c-definitions. 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.

Vitia answered 6/3, 2016 at 2:26 Comment(2)
Have you had any luck with this?Fayola
Any luck with this?Certes
L
1

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/

Lohman answered 12/1, 2019 at 18:51 Comment(0)
H
0

I also ran into this problem when creating a containerized build environment for cross-compiled Qt applications for raspberry pi 4.

I found I needed to edit the mkspec for the linux-rasp-pi4-v3d device and add another cflag so that gcc could find the header from my Raspi sysroot that was used to cross-compile Qt.

Specifically under qtbase/mkspecs/devices/linux-rasp-pi4-v3d-g++/qmake.conf:

QMAKE_CFLAGS            = -march=armv8-a -mtune=cortex-a72 -mfpu=crypto-neon-fp-armv8 -I$$[QT_SYSROOT]/usr/include/arm-linux-gnueabihf
Heiress answered 29/4, 2021 at 17:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.