上个月装了qt-creator-linux-x86-opensource-2.2.1 ,嵌入式arm版的源码也编译成功了,但是移植arm的
qmake 一直用不了,拖一个月,没能搞清楚是怎么回事,今天晚上突然想看一看是怎么回事,于是,又
遍了一个Qt程序。
用pc机qtcreator自带的qmake能编译通过,但是用嵌入式arm的不行,在构建的时候老是提示错误:
home/quan/nfsroot/workspace/output/arm-linux/qt/include/QtCore/qatomic_arm.h: Assembler messages:
/home/quan/nfsroot/workspace/output/arm-linux/qt/include/QtCore/qatomic_arm.h:131: Error: no such instruction: `swpb %bl,%al,[%edx]'
`swpb %bl,%al,[%edx]' 这指令,明显是x86的指令,而不是arm的指令,回头看了一下Qt的编译输出:
g++ -c -m32 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/home/quan/nfsroot/workspace/output/arm-linux/qt/mkspecs/linux-g++-32 -I/home/quan/tmp/qt/animation/animatedtiles -I/home/quan/nfsroot/workspace/output/arm-linux/qt/include/QtCore -I/home/quan/nfsroot/workspace/output/arm-linux/qt/include/QtGui -I/home/quan/nfsroot/workspace/output/arm-linux/qt/include -I. -I/home/quan/tmp/qt/animation/animatedtiles -I. -o main.o /home/quan/tmp/qt/animation/animatedtiles/main.cpp
问题应该就出现在/home/quan/nfsroot/workspace/output/arm-linux/qt/mkspecs/linux-g++-32
在编译成obj文件的时候应该不是用arm-none-linux-gnueabi-g++编译出来的,而是用linux-g++-32编译
出来的。
进入工程文件,看了一下生成的main.o
[quan@ThinkPad 1]$ file main.o
main.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
果然不是x86指令
[quan@ThinkPad qws]$cd /home/quan/nfsroot/workspace/lib/qt4.7.4/mkspecs/qws
[quan@ThinkPad qws]$ cp linux-arm-gnueabi-g++ ../ -R
[quan@ThinkPad qws]$cd /home/quan/nfsroot/workspace/lib/qt4.7.4/mkspecs
cp linux-g++-32 linux-g++-32-bak -R //备份
rm linux-g++-32 -rf
cp linux-arm-gnueabi-g++ linux-g++-32 -R
[quan@ThinkPad qws]$cd linux-g++-32
参照原来的:linux-g++-32
修改qmake.config
include(../common/g++.conf)
include(../common/linux.conf)
include(../common/qws.conf)
修改qplatformdefs.h
"#include "../linux-g++/qplatformdefs.h"
我又傻傻的编译了一遍源码包
=========================================
以上是在源码包修改的,我有重新编译了一边源码包.大概1个小时左右
然后在用qt编原来的那个小程序,通过了.并且移植到arm板上也能跑起来(就一个小窗口程序)
进入工程目录:
[quan@ThinkPad 1]$ file main.o
main.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
这个是货真价实的在arm的obj文件了...
[root@urbetter bin]# ./QT.sh
./1: error while loading shared libraries: libQtGui.so.4: cannot open shared obj
ect file: No such file or directory
路径不对.
修改了一下LD_LIBRARY_PATH
[root@urbetter bin]# ./QT.sh
/workspace/output/arm-linux/qt/lib
QWSSocket::connectToLocalFile could not connect:: No such file or directory
No Qt for Embedded Linux server appears to be running.
If you want to run this program as a server,
add the "-qws" command-line option.
[root@urbetter bin]# ./QT.sh
/workspace/output/arm-linux/qt/lib
QFontDatabase: Cannot find font directory /home/quan/nfsroot/workspace/lib/qt4.7
.4/../../output/arm-linux/qt/lib/fonts - is Qt installed correctly?
Aborted
缺少字库或者字符路径不对,我的情况是字符路径不对
export QT_QWS_FONTDIR=/home/quan/nfsroot/workspace/lib/qt4.7
.4/../../output/arm-linux2/qt/lib/fonts/
按错误提示修改相关配置选项
最终开发板上弹出了一个小窗口.............................
说明:我估计按上面步骤在编译出来的qt/mkspecs里修改一下文件即可,不用重新编译源码也能成功,但是没试过,因为原来我存放编译出来的qt库的文件夹
/home/quan/nfsroot/workspace/output/arm-linux/qt路径已经改变
/home/quan/nfsroot/workspace/output/arm-linux2/qt
============================================
qt-everywhere-opensource-src-4.7.4.tar.gz 移植:
官网下载源码包
解压
./configure -prefix $PWD/../../output/arm-linux/qt -opensource -confirm-license -release -shared -embedded arm -xplatform qws/linux-arm-gnueabi-g++ -depths 16,18,24 -fast -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -little-endian -host-little-endian -no-qt3support -no-libtiff -no-libmng -no-opengl -no-mmx -no-sse -no-sse2 -no-3dnow -no-openssl -no-webkit -no-qvfb -no-phonon -no-nis -no-opengl -no-cups -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -nomake examples -nomake tools -nomake docs -qt-mouse-linuxinput -qt-kbd-linuxinput -qt-gfx-linuxfb -I$PWD/../../output/arm-linux/include -L$PWD/../../output/arm-linux/lib -lasound
-qt-mouse-linuxinput 没用触摸屏,而用的是鼠标
这些配置好多选项不懂.....都是网上看高手们做的. 以后遇到问题相关的在去研究.....
不过qtcreator的文档上也有类似的说明,不过比较简单,还不如直接用网上高手们的成果......具体的选项因开发板而不同吧...
make
make install
新手上路真不容易呀............
//=========================================
在配置选项里添加-qt-mouse-tslib之后,似乎不能加-lts 会出现 tslab functionality test failed 和 ld can not find -lts 之类的错误
阅读(4023) | 评论(1) | 转发(0) |