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

时间:2014-08-07 05:51:27

标签: gcc pthreads cross-compiling gnu

使用Ubuntu 12.04主机,我仔细地按照这个SO答案(Recipe for Compiling Binutils and GCC Together)在一棵树中构建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

我是否错过了阻止此构建的某种依赖项?

P.S。我安装了'build-essential&#39;在构建之前通过apt-get。

1 个答案:

答案 0 :(得分:0)

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

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

在交叉编译器的情况下,一种可能的路线是:

  1. 确保您已预先构建binutils(交叉编译构建)
  2. 交叉编译GCC: 添加配置选项--without-headers。现在编译(参见下面链接中的make targets)
  3. 编译C库并在编译目标程序时指向它
  4. 请参阅GCC Cross Compiling交叉编译gcc的一些说明。然后&#34;安装&#34;适当的C库(glibc / newlib)。

    另外,(如果你还没有这样做),可能值得确保bintutils的--prefix和gcc交叉编译构建是相同的位置。