I start with the not found include/library problem first, since this goes a bit beyond the normal crosstools-ng installation/usage.
The problem is, that crosstools-ng rightfully creates gcc compiler, with a target tuple like: arm-vendor-linux-gnueabihf. This is totally correct. However, Raspian installs includes and libs in folders without vendor string: /lib/arm-linux-gnueabihf. Looks like pkg-config cannot handle this. crosstools-ng might be right with the tuple, but is also a bit heavy handed by refusing to add a function to remove this vendor string. The functions in crosstool-ng, which allow to modify the tuple and the vendor string are not an alternative. They just create symbolic links with a new name, but the tuple is hardcoded in GCC. The only way to properly get rid of the vendor string is to patch the crosstools-ng sources.
So the first step to get a functional Raspberry Pi/Raspian gcc 4.9.1 toolchain is to clone the crosstools-ng repository:
git clone git://crosstool-ng.org/crosstool-ng
Second is to patch sources:
diff --git a/scripts/config.guess b/scripts/config.guess
index dbfb978..9a35943 100755
--- a/scripts/config.guess
+++ b/scripts/config.guess
@@ -176,7 +176,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
- *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH} ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
diff --git a/scripts/config.sub b/scripts/config.sub
index 6d2e94c..f92db2b 100755
--- a/scripts/config.sub
+++ b/scripts/config.sub
@@ -317,7 +317,7 @@ case $basic_machine in
| we32k
| x86 | xc16x | xstormy16 | xtensa
| z8k | z80)
- basic_machine=$basic_machine-unknown
+ basic_machine=$basic_machine
;;
c54x)
basic_machine=tic54x-unknown
The rest is the standard configure/make/make install.
The next step is to configure crosstools-ng correctly to build the desired toolchain. This is done with ct-ng menuconfig
.
Going though every single config item would be extremely lengthy, so I added a working config file here:
http://pastebin.com/MhQKnhpN
It can be imported and with Load an Alternate Configuration File. Finally ct-ng build
builds in a few minutes a new
toolchain. The toolchain is created in {HOME}/x-tools3, as defined in the config file. To change this, change 'Prefix directory' in 'Path and misc options'. But the toolchain can also be moved manually after the build.
The next question/answer will show how to use this toolchain to build a very modern Qt5 for the Raspberry Pi.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…