操作系统:ubuntu 11.04
交叉编译工具链及其路径:arm-none-linux-gnueabi /usr/local/arm/4.3.2
源码:qt-everywhere-opensource-src-4.7.3.tar.gz
移植过程:
1 下载源码,解压,进入解压后文件夹:
#tar zxvf qt-everywhere-opensource-src-4.7.3.tar.gz
#cd qt-everywhere-opensource-src-4.7.3
2 配置QT
./configure -opensource -confirm-license -release -shared -embedded arm -xplatform qws/linux-arm-g++ -depths 4,8,16,18,24,32 -fast -optimized-qmake -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-cups -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -nomake examples -nomake tools -nomake docs qt-mouse-tslib I/usr/local/tslib/include -L/usr/local/tslib/lib
出现错误:
The tslib functionality test failed!
.....
尝试过的解决方法:
(1) 重新正确地安装tslib
(2)更改 ../qt-everywhere-opensource-src-4.7.3/mkspecs/qws/linux-arm-g++/qmake.conf 文件,添加:
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
还是同样问题...
(3) 问题解决....原来是交叉编译工具链设置问题,重新设置环境:
打开/root/.bashrc
最后一行添加export PATH=$PATH:/usr/local/arm/4.3.2/bin
3 make
出现问题:
/work/qt-everywhere-opensource-src-4.7.3/src/tools/bootstrap/libbootstrap.a: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[1]: *** [../../../bin/moc] Error 1
make[1]: Leaving directory `/work/qt-everywhere-opensource-src-4.7.3/src/tools/moc'
make: *** [sub-moc-make_default-ordered] Error 2
原因是没删除之前的配置,
make confclean
make distclean
再依次configure,make,make install就可以了。
4 安装完成后会默认生成/usr/local/Trolltech/QtEmbedded-4.7.3-arm文件夹,如果想更改安装路径,比如安装在/usr/lcoal/qt文件夹下,configure时加-prefix /usr/lcoal/qt参数。接下来要将这个文件和tslib文件夹放到根文件系统中,本来想用U盘拷贝过去的,但是U盘文件系统和linux的ext2不兼容,所以只能考虑用NFS根文件系统。之前配置过没成功,今天再试了下竟然可以了,呵呵。这样我就直接把Trolltech和tslib两个文件夹放到虚拟机里NFS根文件系统里相应文件夹。然后就是编译个qt工程看能否在开发板上正确运行。
5开发板环境设置,OK6410的NFS根文件系统bin目录下有个qt4脚本文件,用于设置环境变量和运行程序,我们只要更改几行内容就可以运行自己的qt程序:
#!/bin/sh
base1=qpe
pid=`/bin/pidof $base1`
if [ -n "$pid" ]; then
killall $base1
fi
base2=qss
pid=`/bin/pidof $base2`
if [ -n "$pid" ]; then
killall $base2
fi
base3=quicklauncher
pid=`/bin/pidof $base3`
if [ -n "$pid" ]; then
killall $base3
fi
base4=fluidlauncher
pid=`/bin/pidof $base4`
if [ -n "$pid" ]; then
killall $base4
fi
export TSLIB_ROOT=/usr/local/tslib
export TSLIB_TSDEVICE=/dev/input/event2
export TSLIB_TSEVENTTYPE=H3600
export TSLIB_CONFFILE=/usr/local/tslib/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/tslib/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export QTDIR=/usr/local/Trolltech/QtEmbedded-4.7.3-arm
export LD_LIBRARY_PATH=$QTDIR/plugins/qtopialmigrate/:$QTDIR/qt_plugins/imageformats/:$QTDIR/lib:/root/tslib/build/lib:$LD_LIBRARY_PATH
export PATH=/bin:/sbin:/usr/bin/:/usr/sbin:/root/tslib/build/bin
if [ -c /dev/input/event2 ]; then
export QWS_MOUSE_PROTO="Tslib:${TSLIB_TSDEVICE}"
if [ -e /etc/pointercal -a ! -s /etc/pointercal ] ; then
rm /etc/pointercal
/root/tslib/build/bin/ts_calibrate
fi
else
export QWS_MOUSE_PROTO="MouseMan:/dev/input/mice"
>/etc/pointercal
fi
export QWS_KEYBOARD=TTY:/dev/tty1
FB_SIZE=$(cat /sys/class/graphics/fb0/virtual_size)
#export QWS_DISPLAY="LinuxFb:mmWidth76:mmHeight44:1"
case "$FB_SIZE" in
800,480)
export QWS_DISPLAY="LinuxFb:mmWidth91:mmHeight53:1"
;;
480,272)
export QWS_DISPLAY="LinuxFb:mmWidth76:mmHeight44:1"
;;
*)
export QWS_DISPLAY="LinuxFb:mmWidth91:mmHeight53:1"
;;
esac
#export QWS_DISPLAY=:1
export HOME=/root/QtE4Home
cd /bin
./hello -qws
我更改的地方有:
export QTDIR=/usr/local/Trolltech/QtEmbedded-4.7.3-arm
最后两行:
cd /bin
./hello -qws
hello是我在PC机linux上交叉编译后得到的可执行文件,放在bin文件夹下。
程序在开发板上正确运行,哈哈。
6 例程hello的交叉编译。
用qt-creator建立hello工程,然后编译,生成pro工程文件。在工程文件夹下执行/usr/local/Trolltech/QtEmbedded-4.7.3-arm/bin/qmake,生成Makefile文件,然后make生成可执行文件hello,将hello拷贝到开发板bin文件夹下。