【问题标题】:Raspberry Pi -fatal error: sys/cdefs.h: No such file or directoryRaspberry Pi - 致命错误:sys/cdefs.h:没有这样的文件或目录
【发布时间】:2016-06-19 17:48:51
【问题描述】:

我正在尝试使用最新的 Raspbian 系统映像在我的 Raspberry Pi 上编译 gcc5.3.0。

$ ./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

但是,原来的编译器 (gcc4.9) 在编译 libgcc 时抱怨没有创建 sys/cdefs.h。

我检查了我安装了libc6-devbuild-essential

所以我使用grep -R 'cdefs' /usr/include/ 搜索它,我在/usr/include/bsd/ 找到了它。我创建了 sys 目录并在 /usr/include/bsd/sys 下创建了指向这些头文件的硬链接。

这一次它给了我一个更奇怪的错误, /usr/include/stdio.h:312:8: 错误:未知类型名称“文件”。

我在 stackoverflow 上搜索了这个,有一个类似的问题,https://stackoverflow.com/a/21047237/5691005。但是当我删除/usr/include/sys和/usr/include/bsd,然后重新安装libc6-dev时,在/usr/include下找不到sys/cdefs.h,编译器仍然报错。

我现在完全迷路了。任何建议将不胜感激。

【问题讨论】:

  • 你有什么运气吗?
  • 这个运气好吗?

标签: raspberry-pi2 libgcc gcc5


【解决方案1】:

我在编译 gcc-8.2 时遇到了类似的问题。我尝试按照here 的描述重新安装:

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

之后我找到了所有丢失的标题:

find / -name cdefs.h 

并将它们复制到 /usr/include: 这些步骤只允许继续前进,但我仍然没有设法完全构建 gcc。

我找到的最佳解决方案是从以下位置下载已编译的 gcc-8.1 版本: https://solarianprogrammer.com/2017/12/07/raspberry-pi-raspbian-compiling-gcc/

【讨论】:

    【解决方案2】:

    在为树莓派 4 的交叉编译 Qt 应用程序创建容器化构建环境时,我也遇到了这个问题。

    我发现我需要编辑 linux-rasp-pi4-v3d 设备的 mkspec 并添加另一个 cflag,以便 gcc 可以从我的 Raspi sysroot 中找到用于交叉编译 Qt 的标头。

    具体下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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-07
      • 1970-01-01
      • 2023-03-25
      • 2017-05-09
      • 2021-05-15
      • 2014-10-31
      • 2022-01-11
      相关资源
      最近更新 更多