GCC:为 ARM 构建交叉编译器 - 找不到 pthread.h

问题描述 投票:0回答:1

使用 Ubuntu 12.04 主机,我仔细遵循此处的 SO 答案(一起编译 Binutils 和 GCC 的食谱),在一个树中构建 GCC 和 binutils 及其所有依赖项。

这是我在构建目录中执行的配置行:

    ../gcc-4.9.0/configure --target=arm-linux-gnueabi --prefix=/home/mint/cross-arm --disable-werror

Makefile 配置正确,然后我运行:

    sudo make -j8

我进入编译过程一段时间,最终出现错误:

    In file included from ../../../gcc-4.9.0/libgcc/gthr.h:148:0,
             from ../../../gcc-4.9.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory
#include <pthread.h>
                 ^
compilation terminated.
make[2]: *** [_gcov_flush.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from ../../../gcc-4.9.0/libgcc/gthr.h:148:0,
             from ../../../gcc-4.9.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory
#include <pthread.h>
                 ^
compilation terminated.
make[2]: *** [_gcov_execlp.o] Error 1
In file included from ../../../gcc-4.9.0/libgcc/gthr.h:148:0,
             from ../../../gcc-4.9.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory
#include <pthread.h>
                 ^
In file included from ../../../gcc-4.9.0/libgcc/gthr.h:148:0,
             from ../../../gcc-4.9.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory
#include <pthread.h>
                 ^
compilation terminated.
make[2]: compilation terminated.
*** [_gcov_fork.o] Error 1
make[2]: *** [_gcov_execl.o] Error 1
In file included from ../../../gcc-4.9.0/libgcc/gthr.h:148:0,
             from ../../../gcc-4.9.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory
#include <pthread.h>
                 ^
compilation terminated.
make[2]: *** [_gcov_execle.o] Error 1
make[2]: Leaving directory `/home/mint/Workspaces/src/build/arm-linux-gnueabi/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/mint/Workspaces/src/build'
make: *** [all] Error 2

我是否缺少某种阻碍此构建的依赖项?

附注我在构建之前通过 apt-get 安装了“build-essential”。

gcc pthreads cross-compiling gnu
1个回答
0
投票

该错误表明 C 库存在一些问题。

要构建 GCC 编译器,您需要预构建的 binutils + 预构建的 C 库。

如果是交叉编译器,一种可能的途径是:

  1. 确保您已预构建 binutils(交叉编译构建)
  2. 交叉编译GCC: 添加配置选项 --without-headers。现在编译(请参阅下面链接中的 make 目标)
  3. 编译你的C库并在为目标编译你的程序时指向它

请参阅此处GCC 交叉编译有关交叉编译 gcc 的一些说明。然后“安装”适当的 C 库(glibc / newlib)。

另外,(如果您还没有这样做)可能值得确保 bintutils 的 --prefix 和 gcc 交叉编译版本位于同一位置。

© www.soinside.com 2019 - 2024. All rights reserved.