linux - 构建交叉编译器: pthread. h:没有这样的文件或目录

标签 linux gcc makefile g++

我目前正在尝试为 aarch64-linux-gnu 目标编译我自己的 gcc 9.1.0 交叉编译器。我使用了这个教程:https://wiki.osdev.org/GCC_Cross-Compiler

gcc 和 g++ 编译器的编译进度似乎没有错误地完成,但当我尝试使用命令 make all-target-libgcc 编译 libgcc 时,我总是这样遇到这个错误:

In file included from ../../../gcc-9.1.0/libgcc/gthr.h:148,
                 from ../../../gcc-9.1.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:10: fatal error: pthread.h: No such file or directory
   35 | #include <pthread.h>
      |          ^~~~~~~~~~~
compilation terminated.

g++ --version 在我的构建机器上打印:

g++ (GCC) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我的 gcc 配置命令是: ../gcc-9.1.0/configure --target=$TARGET --prefix="$PREFIX"--disable-nls --without-headers 与:

export TARGET=aarch64-linux-gnu
export PREFIX=/opt/aarch64-linux-gnu

我忘记了什么?

最佳答案

来自 GCC 安装手册:

In order to build GCC, the C standard library and headers must be present for all target variants for which target libraries will be built (and not only the variant of the host C++ compiler).

所以你需要一个 aarch64 的 libc。

如果你想自己构建它,Preshing 有一个很好的 article关于这个主题,我还没有完整阅读,但无论如何推荐。他甚至有一张图片提到了 pthread.hlibgcc.a

据我所知,GCC 可以获取到 newlib 源的符号链接(symbolic link),并在使用目标库构建完整交叉编译器的过程中自动构建它。不确定 Glibc。

关于linux - 构建交叉编译器: pthread. h:没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56225533/

相关文章:

linux - 如何使用 Perl 脚本列出文件的行号?

c - 如何在 makefile 中编写通用命令?

c - make 是否适合选择要包含的功能

perl - cpan(1) 失败,返回 'Cannot allocate memory'

c++ - MacOS 共享库 : Undefined symbols for architecture x86_64

linux - 递归编辑特定名称的文件

linux - awk 或 sed 更改文件中的列值

c - 应用程序的稳健正常关闭

c++ - 为什么 clang 或 gcc 不标记这种从 double 到 int 的隐式转换?

c - gcc 栈内存分配