系统环境:
主机操作系统:Fedora10
主机编译器:gcc
版本 4.3.2
交叉编译器:arm-linux-gcc 4.3.3
软件安装包:
qt-embedded-linux-opensource-src-4.5.3.tar.gz
qt-x11-opensource-src-4.5.3.tar.gz
前提条件:要先把板子的LCD和触屏驱动以及tslib1.4移植好,具体参考TQ2440触摸屏驱动及tslib-1.4移植
一.编译安装qt-x11
qt-x11版本可以产生Qt开发工具,如qmake、designer、qvfb等等。借助qvfb工具就可以在PC上仿真开发Qt
Embedded
的应程序.
1.编译安装qt-x11到/usr/local/qt-x86目录(进入到Qt目录)
#cd /home/wyd/Qt
#tar xvzf
qt-x11-opensource-src-4.5.3.tar.gz
#cd qt-x11-opensource-src-4.5.3
#./configure -prefix /usr/local/qt-x86 -no-openssl
Which edition of Qt do you want to use
?
//那个版本的Qt你想使用
Type 'c' if you want to use the Commercial Edition.
//输入’C’如果你想使用商业版
Type 'o' if you want to use the Open Source Edition.
//输入’o’如果你想使用开源版 O//输入‘o’选择使用开源版
This is the Qt for Linux/X11 Open Source Edition.
//这是开源版的Qt Linux/X11
You are licensed to use this software under the terms of
the Lesser GNU General Public License (LGPL) versions 2.1.
//你是授权使用条件下,此软件较小的GNU通用公共许可证(LGPL协议)版本2.1
You are also licensed to use this software under the terms of
the GNU General Public License (GPL) versions 3.
//你也许可使用条件下,此软件在GNU通用公共许可证(GPL)版本3
Type '3' to view the GNU General Public License version 3.
//输入‘3’查看GNU通用公共许可证版本3
Type 'L' to view the Lesser GNU General Public License version
2.1.
//输入‘L’查看GNU通用公共许可证2.1版
Type 'yes' to accept this license offer.
//输入“yes”接受此授权提供
Type 'no' to decline this license offer.
//输入“no”拒绝此授权提供
Do you accept the terms of either license?
yes //你是否接受许可条款,这里输入“yes”
#make (大约要三个小时)
#make install
2.编译安装qvfb
执行完上面的步骤后,然后就可以编译安装qvfb了。
#cd
qt-x11-opensource-src-4.5.3/tools/qvfb/
#make
#make install
这样qvfb就被安装到/usr/local/qt-x86/bin目录下了。
3.设置环境变量
#vi /etc/profile
然后将/usr/local/qt-x86/bin这个目录加进去就行了
二.编译安装qt-embedded(进入到Qt目录)
#tar xvzf
qt-embedded-linux-opensource-src-4.5.3.tar.gz
#mv qt-embedded-linux-opensource-src-4.5.3 qte-arm
编译安装qte-arm (进入到qte-arm目录)
#./configure -embedded arm -xplatform
qws/linux-arm-g++ -no-mouse-linuxtp -qt-mouse-tslib
-I/usr/local/tslib/include -L/usr/local/tslib/lib -no-qt3support
-no-openssl( -nomake 后面加你不想编译的文件夹。如:-nomake demos)
(注:编译选项-qt-mouse-tslib需要用到触摸屏功能的动态库,所以得把之前编译安装的tslib库包含进来)
#make
#make
install
3.为了方便使用qte-arm工具链来编译程序,必要的环境变量还是得设置一下的。其实,在编译Qt程序时,我们一般只是使用到了qmake工具,所以只要在~/.bashrc中添加几个alias就可以了。
#vi
~/.bashrc
这里添加:
alias
qvfb='/usr/local/qt-x86/bin/qvfb -width 640
-height 480'
alias
qte-arm-make='/usr/local/qte-arm/bin/qmake'
三.移植Qt库到开发板上
进入qte-arm安装目录,即/usr/local/qte-arm/lib.
输入命令:#cp libQtCore.* libQtGui.*
libQtNetWork.*
/home/wyd/nfs/rootfs/usr/local/qtlib/(其中/home/wyd/nfs/rootfs是开发板文件系统的根目录)
然后修改根文件系统的 /etc/profile文件
#cd /home/wyd/nfs/rootfs/
#vi etc/profile
添加如下语句:
export
QTLIB_ROOT=/usr/local/qtlib
export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTLIB_ROOT
export QWS_SIZE=480x272
export
QWS_MOUSE_PROTO="Tslib:/dev/event0"
保存退出!
然后再找一个Qt例子,如wiggly.拷贝到/home/wyd/nfs/rootfs/bin目录下。
然后启动开发板,在超级终端运行wiggly.(此时如果提示缺少某个共享库则找到对应的库拷贝到根文件系统的/lib目录下即可)
产生一个错误:找不到fonts文件夹!
这时只需将/usr/local/qte-arm/lib/fonts
拷贝到根文件系统的/usr/local/qte-arm/lib/目录下即可
执行命令:
#cp -r /usr/local/qte-arm/lib/fonts
/home/wyd/nfs/rootfs/usr/local/qte-arm/lib/
然后在执行wiggly 程序就运行起来了
如果显示的字很小都看不清,就在根文件系统的 /etc/profile文件中加一句:
export
QWS_DISPLAY="LinuxFb:mmWidth35:mmHeight45:0"
保存退出,使其生效!
再执行wiggly 程序,字就看得清了。