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



使用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

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

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

在交叉编译的情况下,一个可能的路径是:
    确保你有预构建的binutils(交叉编译构建)交叉编译GCC:添加Configure选项——without-headers。现在编译(参见下面链接中的make targets)
  1. 编译你的C库,并在为目标编译程序时指向它

在这里查看交叉编译的一些说明。然后"安装"相应的C库(glibc/newlib)。

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

最新更新