# modifications to g++.conf
QMAKE_CC = /usr/local/arm/3.4.1/bin/arm-linux-gcc -lts QMAKE_CXX = /usr/local/arm/3.4.1/bin/arm-linux-g++ -lts QMAKE_LINK = /usr/local/arm/3.4.1/bin/arm-linux-g++ -lts QMAKE_LINK_SHLIB = /usr/local/arm/3.4.1/bin/arm-linux-g++ -lts
# modifications to linux.conf
QMAKE_AR = /usr/local/arm/3.4.1/bin/arm-linux-ar cqs QMAKE_OBJCOPY = /usr/local/arm/3.4.1/bin/arm-linux-objcopy QMAKE_STRIP = /usr/local/arm/3.4.1/bin/arm-linux-strip
load(qt_config)
Note:
QMAKE_INCDIR QMAKE_LIBDIR
+=/opt/mini2440/root_nfs/tslib/include +=/opt/mini2440/root_nfs/lib
这两行必须放在”include”语句后面,而且QMAKE_INCDIR和QMAKE_LIBDIR是指向的开发板共享的路径,而不是存放在本机中的路径,因为这里面有tslib 触摸屏测试,不然肯定configure 不过去!
运行./autoconfig.sh 生成makefile文件,生成成功最后会输出如下信息
Qt is now configured for building. Just run 'make'. Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/Trolltech/QtEmbedded-4.8.4-arm
To reconfigure, run 'make confclean' and 'configure'.
接下来执行make,make过程中会出现一些错误,有些是程序本身的一些bug,比较典型的有:
(1) ../../include/QtCore/../../src/corelib/arch/qatomic_armv5.h:236: error: `count' was not
declared in this scope
修复:
/src/corelib/arch/qatomic_armv5.h发现原来是漏了一句
int count = 0;
分别在236和373所在的函数定义处补上. (2)
obj/release-shared-emb-mips/qthread_unix.o: In function `set_thread_data(QThreadData*)':
qthread_unix.cpp.text+0xec): undefined reference to `__tls_get_addr'
修复:
关掉该宏后再编译
#if defined(Q_OS_LINUX) && defined(__GLIBC__) && (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) //#define HAVE_TLS
(3) {standard input}: Assembler messages:
{standard input}:778: Error: register or shift expression expected -- `orr r3,r2,lsl#16' 修复:sudo gedit /src/3rdparty/freetype/include/freetype/config/ftconfig.h Line 330. change
\ to \
(4) lib/libQtGui.so: undefined reference to `ts_read_raw'
解决办法:
'修改qt-everywhere-opensource-src-4.7.2/mkspecs/qws/linux-arm-g++/qmake.conf 文件(添加lts参数):
QMAKE_CC = arm-linux-gcc -lts QMAKE_CXX = arm-linux-g++ -lts QMAKE_LINK = arm-linux-g++ -lts QMAKE_LINK_SHLIB = arm-linux-g++ -lts
最后make install安装,安装完成后可以在安装目录/usr/local/qte-arm 下查看对应文件,如下图:
提醒:对4.8.4中的代码修改后最好重新打包,以方便以后使用.
开发板配置
在开发板上的使用其实很简单,只需要拷贝相应的库文件并设置环境变量即可,拷贝的方法按照个人喜好,我是挂载nfs来实现拷贝。 cp –rf /usr/local/qte-arm /opt/mini2440/root_nfs/ 设置环境变量:sudo gedit /opt/mini2440/root_nfs/etc/profile
# Ash profile # vim: syntax=sh
# No core files by default ulimit -S -c 0 > /dev/null 2>&1
USER=\LOGNAME=$USER PS1='[\%u@\\h \\W]\\# ' PATH=$PATH
HOSTNAME=`/bin/hostname`
#export USER LOGNAME PS1 PATH
# tslib path
export TSLIB_TSDEVICE=/dev/input/ts0 export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb0 export PATH=/tslib/bin:$PATH
export LD_LIBRARY_PATH=$LIBRARY_PATH:/lib
# qt path
export QTDIR=/qte-arm export QTDIRlib=/qte-arm/lib
export LD_LIBRARY_PATH=$QTDIRlib:$LD_LIBRARY_PATH export PATH=$QTDIR/bin:$PATH
export QWS_MOUSE_PROTO=tslib:/dev/input/ts0
export QWS_DISPLAY=\export QT_QWS_FONTDIR=/qte-arm/lib/fonts
Qt开发环境的配置
启动QDevelop,Tools?External Tools:
只需要修改第一个qmake的路径,将其改为qt for arm的就行。然后build,复制编译好的二进制文件到2440的NFS文件系统的某个目录下(如果是nfs挂载的话,不用复制,直接在NFS系统里面调试,build 后直接在开发板上运行即可). 这样在开发板终端打入命令:
#./hellovector -qws (-qws一定要加上)
注意:有可能你在虚拟机里面运行一个qt显示正常,而移植到开发板后,图像变形了,如下所示:
这时就需要修改你的UI 的geometry 属性,将其改为setGeometry (0, 0, 240, 320) (从屏幕上(0,0)位置开始(即为最左上角的点),显示一个240*320的界面(宽240,高320)).修改后编译过的图如下: