问题描述
至少Debian并没有提供可用的工具链来为Raspberry Pi 1进行交叉开发。Linaro toochain在写这篇文章时已经过时了,不适合Qt5开发者分支。有一个项目crosstools-ng,它允许轻松地为各种系统构建定制工具链。它支持一个相当现代的GCC 4.9.1。该配置有点试错,但主要问题是,工具链没有找到所有的包含文件或库。如何配置crosstools-ng,以便它可以用于编译Raspberry Pi 1的Qt5?跟进Raspian Raspberry Pi如何准备使用这个工具链可以在这里找到:
我首先找到未找到的包含/库问题,因为这比普通的crosstools-ng安装/使用稍微多一点。
问题是,crosstools-ng正确地创建了gcc编译器,并带有如下的目标元组:arm-vendor-linux-gnueabihf。这是完全正确的。然而,Raspian在没有供应商字符串的文件夹中安装include和libs:/ lib / arm-linux-gnueabihf。看起来像pkg-config无法处理这个问题。 crosstools-ng可能是正确的元组,但是也有点沉重,拒绝添加一个函数来删除这个供应商字符串。 crosstool-ng中允许修改元组和供应商字符串的函数不是替代方案。他们只是用一个新名字创建符号链接,但是元组在GCC中是硬编码的。正确地摆脱供应商字符串的唯一方法是修补crosstools-ng资源。
因此,获得功能性Raspberry Pi / Raspian gcc 4.9的第一步。 1工具链是克隆crosstools-ng存储库:
git clone git://crosstool-ng.org/crosstool-ng
其次是补丁来源:
diff --git a / scripts / config.guess b / scripts / config.guess
index dbfb978..9a35943 100755
--- a / scripts / config。猜测
+++ 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
#操作系统包括对象格式,如果它最近已将
#切换到ELF,或将来会切换到ELF。
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
其余部分是标准配置/ make / make install。
下一步是正确配置crosstools-ng来构建所需的工具链。这是通过 ct-ng menuconfig
。
完成的。尽管每一个配置项目都会非常冗长,所以我在这里添加一个工作配置文件:
可以导入它并使用加载备用配置文件。最后 ct-ng build
会在几分钟内生成一个新的
工具链。工具链在配置文件中定义的{HOME} / x-tools3中创建。要更改它,请在'路径和其他选项'中更改'前缀目录'。但是工具链也可以在构建后手动移动。
At least Debian does not provide a usable toolchain to cross develop for the Raspberry Pi 1. The Linaro toochain is at the time of this writing too old for the Qt5 developer branch. There is a project crosstools-ng, which allows to easily build custom toolchains for all kinds of systems. It supports a fairly modern GCC 4.9.1. The configuration is a bit trial and error, but the main problem is, that the toolchain does not find all the include files or libraries. How is the crosstools-ng to be configured so it can be used to compile Qt5 for the Raspberry Pi 1?
A followup how a Raspberry Pi with Raspian has to be prepared to use this toolchain can be found here:How do I prepare a Raspberry Pi with Raspbian so I can cross compile Qt5 programs from a Linux host?
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 newtoolchain. 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.
这篇关于我如何为Raspberry Pi 1创建一个现代的交叉编译工具链?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!