'GCC: Building cross-compiler for ARM - pthread.h not found
Using a Ubuntu 12.04 host, I carefully followed this SO answer here (Recipe for Compiling Binutils and GCC Together) to build GCC and binutils in one tree with all of their dependencies.
Here is the configure line I am doing inside my build directory:
../gcc-4.9.0/configure --target=arm-linux-gnueabi --prefix=/home/mint/cross-arm --disable-werror
The Makefile configures correctly and afterwards I run:
sudo make -j8
I get into the compilation process for some time then eventually it errors out here:
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
Am I missing a certain dependency that is preventing this build?
P.S. I installed 'build-essential' via apt-get before the build.
Solution 1:[1]
The error suggests some issue with the C library.
For building the GCC compiler, you need prebuilt binutils + prebuilt C library.
In case of cross compiler, one possible route is :
- Ensure that you have prebuilt binutils (cross compile build)
- Cross compile GCC : Add Configure option --without-headers. Now compile (see make targets in the link below)
- Compile your C library and point to it when compiling your program for the target
See some instructions for cross-compiling gcc here GCC Cross Compiling. Then "install" the appropriate C library (glibc / newlib).
Also, (if you are not already doing it) it may be worthwhile to ensure that the --prefix for bintutils and the gcc cross compile build are the same location.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |