交叉的问题,从源头为ARM编译的Qt 4.7 [英] Problems cross compiling Qt 4.7 from source for ARM
问题描述
我试图交叉编译的Qt 4.7.1从源代码,这里有我的设置一些注意事项:
- 我的预期成果是所需要的是为了运行一个Qt应用程序present共享对象库。
- 我的目标平台是TI AM335x处理器,它是ARM的Cortex-A8架构的。
- 我的开发平台是x86的64位的Ubuntu虚拟机
我如何这应该工作的理解是,我下载工具链为我的目标平台(这是的从TI Linaro的工具链),我下载的源$ C $ c代表的的Qt 4.7.1 ,我设置了mkspec用我的工具链,运行配置
,然后只需运行制作
/ 使安装
,我应该能够找到所有的的.so
的我在哪里告诉它安装到。我有很多问题得到这个想法但是工作。
首先,我下载的TI SDK版本:TI-SDK-am335x-EVM-06.00.00.00有手臂工具的位置: [root_install_dir] / linux下的devkit / sysroots / i686的-阿拉戈Linux的的/ usr / bin中
我更新了我的 $ PATH
与目录:
迈克@麦克 - VirtualBox的:〜$回声$ PATH
/home/mike/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin
:/usr/local/Trolltech/Qt-4.8.5/bin:/家庭/麦克/斌:/ usr / lib目录/ lightdm / lightdm:
在/ usr / local / sbin中:在/ usr / local / bin目录:/ usr / sbin目录:在/ usr / bin中:/ sbin目录:/ bin中:在/ usr /游戏:/家庭/麦克风/斌
块引用>我再根据最近的例子创建了自己的mkspec:
CP -R [qt_install_dir] / mkspecs / QWS / Linux的臂gnueabi-G ++ / [qt_install_dir] / mkspecs / QWS / Linux的am335x-G ++
和我修改了
Linux的am335x-G ++ / qmake.conf
指向来自TI SDK工具:#修改G ++。CONF
QMAKE_CC =臂Linux的gnueabihf-GCC
QMAKE_CXX =臂Linux的gnueabihf-G ++
QMAKE_LINK =臂Linux的gnueabihf-G ++
QMAKE_LINK_SHLIB =臂Linux的gnueabihf-G ++#修改linux.conf
QMAKE_AR =臂Linux的gnueabihf-AR CQS
QMAKE_OBJCOPY =臂Linux的gnueabihf-objcopy把
QMAKE_STRIP =臂Linux的gnueabihf带钢然后我跑了configure命令:
./配置 - preFIX /home/mike/qt4.7.1_source/my_qt - 嵌入式手臂-platform QWS / Linux的x86_64的-G ++ -xplatform QWS / Linux的am335x-G ++ -no-MMX -NO- 3DNOW -no-SSE -no-SSE2 -no-能说会道-no杯-no-largefile -no-无障碍 - 无 - OpenSSL的-no-的GtkStyle -fast -opensource
块引用>它运行一段时间即可完成,并表示已经准备好做
制作
/制作安装
在这一点上我运行制作
而这也正是它开始失败:
/home/mike/qt4.7.1_source/qt-everywhere-opensource-src-4.7.1/bin/moc
-DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DELF_INTER preTER = \\/ lib64目录/ LD-Linux的x86-64.so.2 \\-DHB_EXPORT = Q_CORE_EXPORT -DQT_HAVE_NEON - DQT_NO_DEBUG -I ../../ mkspecs / QWS / Linux的am335x-G ++ -I。 -I ../../包括-I ../../包括/ QtCore -I.rcc /释放共享EMB-手臂-Iglobal -I ../的3rdParty /的HarfBuzz / src目录-I ../的3rdParty / MD5 -I ../的3rdParty / MD4 -I.moc /释放共享EMB-ARM核/ qobject.h -o .moc /释放共享EMB-ARM / moc_qobject.cpp臂Linux的gnueabihf-G ++ -C
-include .PCH /释放共享EMB-ARM / QtCore哌-fno-例外-mfpu =霓虹灯-O2 -fvisibility =隐藏-fvisibility - 内联隐藏-Wall -W -D_REENTRANT -fPIC -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DELF_INTER preTER = \\/ lib64目录/ LD-Linux的x86-64.so.2 \\-DHB_EXPORT = Q_CORE_EXPORT -DQT_HAVE_NEON -DQT_NO_DEBUG -I ../ ../mkspecs/qws/linux-am335x-g++ -I。 -I ../../包括-I ../../包括/ QtCore -I.rcc /释放共享EMB-手臂-Iglobal -I ../的3rdParty /的HarfBuzz / src目录-I ../的3rdParty / MD5 -I ../的3rdParty / MD4 -I.moc /释放共享EMB-手臂-o .OBJ /释放共享EMB-ARM / qobject.o内核/ qobject.cpp结果{标准输入} :汇编信息:结果
{标准输入}:1294:错误:选择的处理器不支持Thumb模式SWP R6,R4,[R3] 结果
使[1]: [.OBJ /释放共享EMB-ARM / qobject.o]错误1 的*结果使[1]:离开目录
/home/mike/qt4.7.1_source/qt-everywhere-opensource-src-4.7.1/src/corelib结果
令: * 的[子corelib的-make_default有序]错误2
块引用>所以,问题...
为什么编译器抱怨不支持Thumb模式?由于这是一个交叉编译工具链为的 ARM 的处理器,它的应的支持。这不是事实使我觉得制作
莫名其妙地拿起克错版++。这是什么地方出了错,以及如何解决这个问题有什么想法?
解决方案
{标准输入}:1294:错误:选择的处理器不支持Thumb模式的SWP R6,R4,[R3]
为什么编译器抱怨不支持Thumb模式?
块引用>不是可供注意,编译器抱怨
SWP
指令的 Thumb模式的。你的CPU支持的拇指的 thumb2 和 ARM 的。皮质系列德precates使用的SWP
和prefersLDREX / STREX
对。
这是什么地方出了错,以及如何解决这个问题有什么想法?
块引用>您需要让GCC定义
__ __ ARM_ARCH_7
;这是与任何-mcpu = Cortex-A8的
或组合-mtune = Cortex-A8的
和<$ C完成$ C> -march =的ARMv7-A 或你喜欢这取决于你想如何板卡种类很多什么都的Qt 上运行。在细节,请参见<一个href=\"https://qt.gitorious.org/qt/qt/source/11ed361d1d66f011f6bc56d70d3adc4d235c3e52%3asrc/corelib/arch/qatomic_arm.h\"相对=nofollow> qatomic_arm.h 的了解,选择了分档。你有一个非常通用的 ARM 选择(我猜),所以你得到的 qatomic_armv5.h 的 注1 在这里你可以看到周围125线在code为你的CPU的权文件的 qatomic_armv7.h 的,主要只是包括<一个href=\"https://qt.gitorious.org/qt/qt/source/11ed361d1d66f011f6bc56d70d3adc4d235c3e52%3asrc/corelib/arch/qatomic_armv6.h\"相对=nofollow> qatomic_armv6.h 的。在这个文件中,你可以找到
LDREX / STREX
这是你的GCC
正在请求有益健康的善良。我也建议你不要使用的 -fast 的编译。有<一个href=\"http://stackoverflow.com/questions/8120479/qt-embedded-compile-error-fixing-error-no-such-instruction-error\">another问题其中OP说,这解决了他的问题;但我认为这是不同的。
您可以尝试通过
-armfpa
配置。./配置 - 嵌入式手臂--help
是非常有用的。配置
似乎已经选定的 NEON 的,所以它似乎知道你有一个更先进的CPU(没有的 NEON 的上的的ARMv5 的,但是这也许的故障配置
)。有关肯定的,你不想让
SWP
code和LDREX / STREX
为preferred为您的系统,即使SWP
可以以某种方式工作。我至少会解决这个问题。修改-xplatform QWS / Linux的am335x-G ++
更新-mcpu
或可能传递一个明确的-D__ARM_ARCH_7 __
。你可以定义的列表,ARM-GCC -mcpu =皮层-A8 -dM -E - &LT;的/ dev / null的
,以验证__ __ ARM_ARCH_7
被定义。它看起来是MOC
失败了,所以也许在-D__ARM_ARCH_7 _
将需要的解决方案。您也可以尝试改变
-mthumb
在编译器选项。这可能是最好使用-mcpu = Cortex-A8的
和-mthumb
为您的系统,如果你能得到编译/构建。省略-mthumb
将使code稍大。您也可以尝试-Os
。出于某种原因,我的庞大建立与其他优化和更近的GCC
版本。这似乎是由于一些C ++特征为正常的C不行为这种方式;但是这可能只是我的编译器。我看了看,并认为它是异常表,但我从来没有证实任何事情,并继续前行。我相信大家都知道的Qt的花费多长时间进行编译。注1:的 qatomic_armv5.h 的code是相当迷茫和新
GCC
或 binutils的的就会窒息,即使是使用正确的文件。ASM挥发性(SWPB%0%2 [%3]
:=&安培; R(RET),= M(* PTR)
:R(的newval),R(PTR)
:CC,记忆);本规定这是从来没有使用过一些的内联汇编的参数。且不说条件$ C $,不使用CS等。
ASM挥发性(SWPB%0%1 [%2]
:= R(RET)
:0(的newval),R(PTR)
:内存);将与新的
GCC
和的binutils编译的。它也使用较少的寄存器,是最佳的方式的的Qt 的正在使用它;有可能的情况下,其中RET
必须是preserved来比较的newval
,但它仅仅是一个用户空间自旋锁的目前。支架
[X]
是内存操作寄存器中,必须比其他两个参数,一个有效的SWP有所不同
。我认为第一种形式是用来被同停止
。第二形式通过避免了这种0%
3%%0
和%1
一样的,所以%2
必须是不同的。I'm trying to cross-compile Qt 4.7.1 from source, here are some notes on my setup:
- my expected output is the shared object libraries that are required to be present in order to run a Qt application.
- My target platform is a TI AM335x processor which is of the ARM Cortex-A8 architecture.
- My development platform is a x86 64-bit Ubuntu virtual machine
My understanding of how this should work is that I download the toolchain for my target platform (this is the Linaro toolchain from TI), I download the source code for Qt 4.7.1, I set the mkspec to use my tool chain, run
configure
, then just need to runmake
/make install
and I should be able to find all the.so
's where I told it to install to. I'm having a lot of problems getting this idea to work however.
First I downloaded the TI SDK version: ti-sdk-am335x-evm-06.00.00.00 which has the arm tool's at:
[root_install_dir]/linux-devkit/sysroots/i686-arago-linux/usr/bin
I updated my
$PATH
with that directory:mike@mike-VirtualBox:~$ echo $PATH /home/mike/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin :/usr/local/Trolltech/Qt-4.8.5/bin:/home/mike/bin:/usr/lib/lightdm/lightdm: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/mike/bin
I then created my own mkspec based on the closest example:
cp -R [qt_install_dir]/mkspecs/qws/linux-arm-gnueabi-g++/ [qt_install_dir]/mkspecs/qws/linux-am335x-g++
and I modified the
linux-am335x-g++/qmake.conf
to point to the tools from the TI sdk:# modifications to g++.conf QMAKE_CC = arm-linux-gnueabihf-gcc QMAKE_CXX = arm-linux-gnueabihf-g++ QMAKE_LINK = arm-linux-gnueabihf-g++ QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++ # modifications to linux.conf QMAKE_AR = arm-linux-gnueabihf-ar cqs QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy QMAKE_STRIP = arm-linux-gnueabihf-strip
Then I ran a configure command:
./configure -prefix /home/mike/qt4.7.1_source/my_qt -embedded arm -platform qws/linux-x86_64-g++ -xplatform qws/linux-am335x-g++ -no-mmx -no-3dnow -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -fast -opensource
It runs for a while then completes and says it's ready to do
make
/make install
at this point I runmake
and that's where it starts to fail:/home/mike/qt4.7.1_source/qt-everywhere-opensource-src-4.7.1/bin/moc -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DELF_INTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_HAVE_NEON -DQT_NO_DEBUG -I../../mkspecs/qws/linux-am335x-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared-emb-arm -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared-emb-arm kernel/qobject.h -o .moc/release-shared-emb-arm/moc_qobject.cpp arm-linux-gnueabihf-g++ -c -include .pch/release-shared-emb-arm/QtCore -pipe -fno-exceptions -mfpu=neon -O2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DELF_INTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_HAVE_NEON -DQT_NO_DEBUG -I../../mkspecs/qws/linux-am335x-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared-emb-arm -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared-emb-arm -o .obj/release-shared-emb-arm/qobject.o kernel/qobject.cpp
{standard input}: Assembler messages:
{standard input}:1294: Error: selected processor does not support Thumb mode 'swp r6,r4,[r3]'
make[1]: [.obj/release-shared-emb-arm/qobject.o] Error 1*
make[1]: Leaving directory
'/home/mike/qt4.7.1_source/qt-everywhere-opensource-src-4.7.1/src/corelib'
make: * [sub-corelib-make_default-ordered] Error 2So, the question... Why is the compiler complaining that the thumb mode is not supported? Since this is a cross compile tool chain for an ARM based processor, it should be supported. The fact that it's not makes me feel that
make
is somehow picking up the wrong version of g++.Any thoughts on what went wrong and how to fix this?
解决方案{standard input}:1294: Error: selected processor does not support Thumb mode 'swp r6,r4,[r3]'
Why is the compiler complaining that the thumb mode is not supported?
Note, the compiler is complaining about the
swp
instruction not being available for thumb mode. Your CPU supports thumb, thumb2, and ARM. The Cortex series deprecates the use ofswp
and prefersldrex/strex
pairs.Any thoughts on what went wrong and how to fix this?
You need to get gcc to define
__ARM_ARCH_7__
; this is done with either-mcpu=cortex-a8
or the combination-mtune=cortex-a8
and-march=armv7-a
or what ever you like depending on how many types of boards you want Qt to run on.In detail, see qatomic_arm.h for where a sub-file is selected. You have a very generic ARM selected (I guess), so you get qatomic_armv5.hNote1 where you can see the code around line 125. The right file for your CPU is qatomic_armv7.h, which mainly just includes qatomic_armv6.h. In this file you can find
ldrex/strex
which is the wholesome goodness that yourgcc
is requesting.I also suggest you do not compile with -fast. There is another question where the OP says this solved his issue; but I think this is different.
You can try to pass
-armfpa
to configure../configure -embedded arm --help
is useful.configure
appears to have selected NEON, so it seems to know you have a more advanced CPU (there is no NEON on an armv5, but this maybe a fault ofconfigure
).For certain, you don't want the
swp
code and theldrex/strex
is preferred for your system, even ifswp
could somehow work. I would at least resolve this. Alter the-xplatform qws/linux-am335x-g++
to update-mcpu
or possibly pass an explicit-D__ARM_ARCH_7__
. You can get a list of defines witharm-gcc -mcpu=cortex-a8 -dM -E - < /dev/null
, to verify that the__ARM_ARCH_7__
is being defined. It looks like it ismoc
failing, so maybe the-D__ARM_ARCH_7_
solution will be needed.You might also try to alter
-mthumb
in the compiler option. It is probably best to use-mcpu=cortex-a8
and-mthumb
for your system, if you can get that to compile/build. Omitting-mthumb
will make the code slightly larger. You might also try-Os
. For some reason, I have huge builds with other optimizations and more recentgcc
versions. It appears to be due to some C++ feature as normal 'C' doesn't behave this way; but this may just be my compiler. I looked and believe it is the exception tables, but I never confirmed anything and moved on. I am sure you are aware of how long Qt takes to compile.Note1: The qatomic_armv5.h code is fairly confused and newer
gcc
or binutils will choke even when this is the correct file to use.asm volatile("swpb %0,%2,[%3]" : "=&r"(ret), "=m" (*ptr) : "r"(newval), "r"(ptr) : "cc", "memory");
This specifies some inline assembler parameters which are never used. Not to mention the condition codes are not used, etc.
asm volatile("swpb %0,%1,[%2]" : "=r"(ret) : "0"(newval), "r"(ptr) : "memory");
will compile with newer
gcc
and binutils. It also uses less registers and is optimal for the way Qt is currently using it; there maybe cases whereret
needs to be preserved to compare tonewval
but it is just a user space spin lock currently.The bracket
[x]
is a memory operand register and must be different than the other two parameters for a validswp
. I believe the first form was used to stop%0
from being the same as%3
. The 2nd form avoids this by making%0
and%1
the same, so%2
must be different.这篇关于交叉的问题,从源头为ARM编译的Qt 4.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!