简体   繁体   English

从源代码交叉编译Qt 4.7的问题

[英]Problems cross compiling Qt 4.7 from source for ARM

I'm trying to cross-compile Qt 4.7.1 from source, here are some notes on my setup: 我正在尝试从源代码交叉编译Qt 4.7.1,这里有一些关于我的设置的注意事项:

  1. my expected output is the shared object libraries that are required to be present in order to run a Qt application. 我期望的输出是为了运行Qt应用程序而必须存在的共享对象库。
  2. My target platform is a TI AM335x processor which is of the ARM Cortex-A8 architecture. 我的目标平台是采用ARM Cortex-A8架构的TI AM335x处理器。
  3. My development platform is a x86 64-bit Ubuntu virtual machine 我的开发平台是x86 64位Ubuntu虚拟机

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 run make / make install and I should be able to find all the .so 's where I told it to install to. 我对这应该如何工作的理解是我下载了我的目标平台的工具链(这是TI的Linaro工具链),我下载了Qt 4.7.1的源代码,我设置mkspec使用我的工具链,运行configure ,然后只需要运行make / make install ,我应该能够找到我告诉它安装到的所有.so的地方。 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 首先我下载了​​TI SDK版本:ti-sdk-am335x-evm-06.00.00.00,它的arm工具位于: [root_install_dir]/linux-devkit/sysroots/i686-arago-linux/usr/bin

I updated my $PATH with that directory: 我用该目录更新了我的$PATH

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 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 /游戏:/首页/麦克风/箱

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++ 然后我根据最接近的例子创建了我自己的mkspec: 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: 我修改了linux-am335x-g++/qmake.conf以指向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命令:

./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 ./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 run make and that's where it starts to fail: 它会运行一段时间然后完成并说它已准备好make / make install此时我运行make并且它就是它开始失败的地方:

/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. /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 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 -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}:汇编程序消息:
{standard input}:1294: Error: selected processor does not support Thumb mode 'swp r6,r4,[r3]' {标准输入}:1294:错误:所选处理器不支持Thumb模式'swp r6,r4,[r3]'
make[1]: 使[1]: [.obj/release-shared-emb-arm/qobject.o] Error 1 * [.obj / release-shared-emb-arm / qobject.o]错误1 *
make[1]: Leaving directory make [1]:离开目录
'/home/mike/qt4.7.1_source/qt-everywhere-opensource-src-4.7.1/src/corelib' '/home/mike/qt4.7.1_source/qt-everywhere-opensource-src-4.7.1/src/corelib'
make: * [sub-corelib-make_default-ordered] Error 2 make: * [sub-corelib-make_default-ordered]错误2

So, 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. 由于这是基于ARM的处理器的交叉编译工具链,因此应该支持它。 The fact that it's not makes me feel that make is somehow picking up the wrong version of g++. 事实上,它并没有让我觉得make在某种程度上取得了错误的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]' {标准输入}:1294:错误:所选处理器不支持Thumb模式'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 . 注意,编译器抱怨swp指令不适用于拇指模式 Your CPU supports thumb , thumb2 , and ARM . 您的CPU支持thumbthumb2ARM The Cortex series deprecates the use of swp and prefers ldrex/strex pairs. Cortex系列不赞成使用swp并且更喜欢ldrex/strex对。

Any thoughts on what went wrong and how to fix this? 关于出了什么问题以及如何解决这个问题的想法?

You need to get gcc to define __ARM_ARCH_7__ ; 你需要让gcc来定义__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. 这可以通过-mcpu=cortex-a8或组合-mtune=cortex-a8-march=armv7-a或者您喜欢的方式来完成,具体取决于您希望Qt运行多少类型的电路板。

In detail, see qatomic_arm.h for where a sub-file is selected. 有关选择子文件的位置,请参阅qatomic_arm.h You have a very generic ARM selected (I guess), so you get qatomic_armv5.h Note1 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 . 你选择了一个非常通用的ARM (我猜),所以你得到qatomic_armv5.h Note1你可以看到第125行的代码。你的CPU的正确文件是qatomic_armv7.h ,主要包括qatomic_armv6.h In this file you can find ldrex/strex which is the wholesome goodness that your gcc is requesting. 在这个文件中你可以找到ldrex/strex ,它是你的gcc请求的健康善良。

I also suggest you do not compile with -fast . 我还建议你不要用-fast编译。 There is another question where the OP says this solved his issue; 另一个问题是OP说这解决了他的问题; but I think this is different. 但我认为这是不同的。

You can try to pass -armfpa to configure. 您可以尝试通过-armfpa进行配置。 ./configure -embedded arm --help is useful. ./configure -embedded arm --help非常有用。 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 of configure ). configure似乎已经选择了NEON ,所以它似乎知道你有一个更高级的CPU( armv5上没有NEON ,但这可能是configure错误)。

For certain, you don't want the swp code and the ldrex/strex is preferred for your system, even if swp could somehow work. 肯定的是,你不希望你的系统首选swp代码和ldrex/strex ,即使swp可以以某种方式工作。 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__ . 更改-xplatform qws/linux-am335x-g++以更新-mcpu或可能传递显式-D__ARM_ARCH_7__ You can get a list of defines with arm-gcc -mcpu=cortex-a8 -dM -E - < /dev/null , to verify that the __ARM_ARCH_7__ is being defined. 您可以使用arm-gcc -mcpu=cortex-a8 -dM -E - < /dev/null获取定义列表,以验证是否正在定义__ARM_ARCH_7__ It looks like it is moc failing, so maybe the -D__ARM_ARCH_7_ solution will be needed. 看起来它是moc失败的,所以可能需要-D__ARM_ARCH_7_解决方案。

You might also try to alter -mthumb in the compiler option. 您也可以尝试在编译器选项中更改-mthumb It is probably best to use -mcpu=cortex-a8 and -mthumb for your system, if you can get that to compile/build. 如果你可以使用-mcpu=cortex-a8-mthumb来编译/构建,那么最好使用-mcpu=cortex-a8-mthumb Omitting -mthumb will make the code slightly larger. 省略-mthumb将使代码略大。 You might also try -Os . 您也可以尝试-Os For some reason, I have huge builds with other optimizations and more recent gcc versions. 出于某种原因,我有其他优化和更新的gcc版本的庞大版本。 It appears to be due to some C++ feature as normal 'C' doesn't behave this way; 它似乎是由于一些C ++特性,因为正常的'C'不会这样做; 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. 我相信你知道Qt需要多长时间才能编译。

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. 注1: qatomic_armv5.h代码相当混乱,即使这是正确使用的文件,新的gccbinutils也会窒息。

 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 . 将使用较新的gccbinutils进行编译。 It also uses less registers and is optimal for the way Qt is currently using it; 它还使用较少的寄存器,并且最适合Qt当前使用它的方式; there maybe cases where ret needs to be preserved to compare to newval but it is just a user space spin lock currently. 可能存在需要ret以与newval进行比较的情况,但目前只是用户空间旋转锁定

The bracket [x] is a memory operand register and must be different than the other two parameters for a valid swp . 括号[x]是内存操作数寄存器,必须与有效swp的其他两个参数不同。 I believe the first form was used to stop %0 from being the same as %3 . 我相信第一种形式用于阻止%0%3相同。 The 2nd form avoids this by making %0 and %1 the same, so %2 must be different. 第二种形式通过使%0%1相同来避免这种情况,因此%2必须是不同的。

the answer by usr: artless noise did in fact fix my issue, but since I want to make sure there is a very clear trail for myself (if needed) or others, I want to state exactly what the fix was: usr的回答:无艺术的噪音事实上确实解决了我的问题,但由于我想确保自己(如果需要)或其他人有一条非常明确的路径,我想准确说明修复的内容:

First, I updated my .configure command to: 首先,我将.configure命令更新为:

./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 -opensource -qt-mouse-tslib

The only difference from the question's configure command is the removal of the -fast option. 与问题的configure命令的唯一区别是删除-fast选项。

Then in my the linux-am335x-g++/qmake.conf file, I added a few command line options: 然后在我的linux-am335x-g ++ / qmake.conf文件中,我添加了一些命令行选项:

QMAKE_CFLAGS= -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8
QMAKE_CXXFLAGS= -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8

With these two change I can now see everything build and install Qt4.7.1 successfully. 通过这两个更改,我现在可以看到所有内容构建并成功安装Qt4.7.1。

I also tried Qt4.8.5 and everything works the same except one more option has to be added to the ./configure command: 我也尝试过Qt4.8.5并且一切都工作相同,除了必须在./configure命令中添加一个选项:

-no-pch

This is to avoid an error regarding a: .pch directory and files in side showing "No such file or directory" 这是为了避免关于:.pch目录和显示“没有这样的文件或目录”的文件中的文件的错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM