1 准备工作
操作系统:Vmware7.1+Ubuntu9.10,交叉编译器:arm-linux-gcc-3.4.1
1.1 源码包下载
Qt源码包下载:ftp://ftp.trolltech.no/qt/source/
qt-embedded-linux-opensource-src-4.5.3.tar.gz
qt-x11-opensource-src-4.5.3.tar.gz
tslib库下载:http://download.csdn.net/source/2863926
tslib-1.4.tar.gz
1.2 配置Ubuntu9.10编译环境
安装g++:sudo apt-get g++
安装X11库:sudo apt-get install libx11-dev libxext-dev libxext6 libc6 libc6-dev ibfreetype6 libfreetype6-dev libsm-dev libxrender-dev libfontconfig1 libfontconfig1-dev
安装qvfb库:sudo apt-get install libxtst-dev,否则编译qvfb出错
1.3 安装交叉编译器
把arm-linux-gcc-3.4.1.tar.gz复制到/usr/local
# cd /usr/local/qt
# sudo tar xvzf arm-linux-gcc-3.4.1.tar.gz –C / //C 是大写
# export PATH=/usr/local/arm/3.4.1bin:$PATH
这样设置路径变量的方法只在此终端中生效,对其他的终端无效,若要设置对所有用户所有终端都有效的路径变量,在/etc/profile 中最后一行添加“export PATH=/usr/local/arm/3.4.1/bin:$PATH”,保存退出,注销系统即生效。
2 编译安装qt-x11-opensource-src-4.5.3
qt-x11版本可以产生Qt开发工具,如designer、qvfb,嵌入式的开发有了qvfb,就可以不需要实际的开发板,也可以开发Qt应程序。默认安装路径/usr/local/Trolltech。
# tar zxvf qt-x11-opensource-src-4.5.3.tar.gz
# cd qt-x11-opensource-src-4.5.3
# ./configure
# make
# cd tools/qvfb
# make
# cd ../..
# sudo make install
#cp tools/qvfb/qvfb* /usr/local/Trolltech/Qt-4.5.3/bin //将qvfb拷贝到相应目录
环境变量设置:
# cd /usr/local/Trolltech/Qt-4.5.3
# sudo gedit setenv.sh //添加以下内容
PATH=/usr/local/Trolltech/Qt-4.5.3/bin:$PATH
LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.5.3/lib:$LD_LIBRARY_PATH
# source setenv.sh //运行脚本即设置好qt-x11环境变量,可以使用此版本qmake、designer等工具
3 编译安装qt-embedded
3.1编译触摸屏库tslib
安装编译所需要库:
# sudo apt-get install autoconf(或autoconf2.13)
# sudo apt-get install automake
# sudo apt-get install libtool
配置编译:
# tar xzvf tslib-1.4.tar.gz
# cd tslib
# ./ autogen.sh
# ./configure --prefix=/usr/local/tslib/ --host=arm-linux ac_cv_func_malloc_0_nonnull=yes
# make
# make install或make install-strip //生成瘦身应用程序和库
3.2 编译qt-embedded
# tar zxvf qt-embedded-linux-opensource-src.tar.gz
# cd qt-embedded-linux-opensource-src-4.5.3
# ./configure -prefix /usr/local/Trolltech/QtEmbedded-4.5.3-arm -embedded arm -release -shared -fast -no-largefile -qt-sql-sqlite -no-qt3support -no-xmlpatterns -no-mmx -no-3dnow -no-sse -no-sse2 -no-svg -no-webkit -qt-zlib -qt-gif -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -make libs -nomake tools -nomake examples -nomake docs -nomake demo -no-nis -no-cups -no-iconv -no-dbus -no-openssl -xplatform qws/linux-arm-g++ -little-endian -qt-freetype -depths 16,18 -qt-gfx-linuxfb -no-gfx-transformed -no-gfx-multiscreen -no-gfx-vnc -no-gfx-qvfb -qt-kbd-usb -no-glib -qt-mouse-tslib -qt-gfx-qvfb -qt-kbd-qvfb -qt-mouse-qvfb -I/usr/local/tslib/include -L/usr/local/tslib/lib
注意上面的红色目录要跟你的tslib安装目录相同!!!
# make
# sudo make install
环境变量设置:
# sudo gedit setenv-arm.sh
QTEDIR=/usr/local/Trolltech/QtEmbedded-4.5.3-arm
PATH=/usr/local/Trolltech/QtEmbedded-4.5.3-arm/bin:$PATH
LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.5.3-arm/lib:$LD_LIBRARY_PATH
4 移植到YC2440开发板
两种方法:下载至开发板、nfs挂载。
4.1 下载至开发板
把tslib、qt-embedded运行库拷贝到开发板,在/etc/profile中设置环境变量。
# mkdir /usr/local/Trolltech/qtembedded-4.5.3-arm/bin
# mkdir /usr/local/Trolltech/qtembedded-4.5.3-arm/lib/fonts
# mkdir /usr/local/tslib
# vi /etc/profile
export QTDIR=/usr/local/Trolltech/qt-embedded-4.5.3-arm
export QPEDIR=/usr/local/Trolltech/qt-embedded-4.5.3-arm
export PATH=$QTDIR/bin:$PATH
export TSLIB_ROOT=/usr/local/tslib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/h3600_tsraw
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_CALIBFILE=/etc/pointercal
export POINTERCAL_FILE=/etc/pointercal
export QWS_MOUSE_PROTO="Tslib:/dev/h3600_tsraw"
export QWS_DISPLAY=LinuxFb:/dev/fb0
export QWS_SIZE=240x320
export QT_QWS_FONTDIR=$QTDIR/lib/fonts
export LD_LIBRARY_PATH=$TSLIB_ROOT/lib:$QTDIR/lib:/lib:/mnt:LD_LIBRARY_PATH
配置触摸屏:
修改2440上/usr/local/tslib/etc/ts.conf 文件:把第二行# module_raw input 前面的#和空格去除,保存退出
# cd /usr/local/tslib/bin
# ./ts_calibrate //校准触摸屏
# ./ts_test // 测试触摸屏
4.2 nfs挂载共享
配置nfs服务器,把相应库拷贝至共享文件,在终端运行环境变量。
# ifconfig eth0 192.168.1.7
# mount -t nfs -o intr,nolock,rsize=1024,wsize=1024 192.168.1.8:/utu2440 /mnt
# export QTDIR=/mnt/Trolltech/qt-embedded-4.5.3-arm
# export QPEDIR=/mnt/Trolltech/qt-embedded-4.5.3-arm
# export PATH=$QTDIR/bin:$PATH
# export TSLIB_ROOT=/mnt/Trolltech/tslib
# export TSLIB_CONSOLEDEVICE=none
# export TSLIB_FBDEVICE=/dev/fb0
# export TSLIB_TSDEVICE=/dev/h3600_tsraw
# export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
# export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
# export TSLIB_CALIBFILE=/etc/pointercal
# export POINTERCAL_FILE=/etc/pointercal
# export QWS_MOUSE_PROTO="Tslib:/dev/h3600_tsraw"
# export QWS_DISPLAY=LinuxFb:/dev/fb0
# export QWS_SIZE=240x320
# export QT_QWS_FONTDIR=$QTDIR/lib/fonts
# export LD_LIBRARY_PATH=$TSLIB_ROOT/lib:$QTDIR/lib:/lib:/mnt:LD_LIBRARY_PATH