QT简介就不多说了,是诺基亚的东东,需求:将QT移植到ARM开发环境
首先的准备工作:
Linux环境: Linux 2.6.32-24-generic Ubuntu10.04
交叉编译工具:arm-linux- g++-4.4.3
Qt安装包: qt-everywhere-opensource-src-4.6.2.tar.gz
tslib库: tslib-1.4.tar.gz
然后就开始各种编译了:
一、编译tslib库 1>编译 tar zxvf tslib1.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 2>拷贝PC上/usr/local/tslib/* 的文件到开发板目录下的/usr/local cp /usr/local/tslib/* /home/profiles/2440/rootfs/usr/local -rfd 注意:/home/profiles/2440/rootfs/是nfs文件系统的根目录,注意跟自己的环境差异,随机应变即可 二、编译嵌入式qt 1>编译
tar zxvf qt-everywhere-opensource-src-4.6.2.tar.gz
cd qt-everywhere-opensource-src-4.6.2 ./configure \ -prefix /usr/local/qt-4.6.2-arm \ (安装路径) -opensource \ (自由版本) -confirm-license \ (遵守协议yes) -release \ (编译和连接QT时关闭调试) -shared \ (使用QT动态库) -embedded arm \ (嵌入式arm架构) -xplatform qws/linux-arm-g++ \ (交叉编译时的目标平台) -no-qt3support \ (关闭QT3支持功能) -fast \ (只对库及子目录make来快速配置QT) -no-largefile \ (使大文件支持无效) -qt-mouse-tslib \ (使用tslib来驱动鼠标箭头运行,即支持触摸屏) -I /usr/local/tslib/include \ (添加一个显式的include路径) -L /uar/local/tslib/lib \ (添加一个显式的lib路径) -make tools \ (构建tools) -nomake demos \ (不构建demos) -nomake examples \(不构建examples) -nomake docs \ (不构建docs) -qt-libjpeg \ (使用jpeg库) -qt-libpng \ (使用png库) -qt-libtiff \ (使用tiff库) -multimedia \ (构建QT多媒体模块) -no-qvfb \ (不构建QVFB模块) -no-svg \ (不构建SVG模块) -no-cups \ (不编译CUPS支持) 2>拷贝 cp /usr/local/qt-4.6.2-arm /home/profiles/2440/rootfs/usr/local/qt-4.6.2-arm -rfd 3>更改为大字体,并且支持中文,wenquanyi_120_50.qpf需要下载 (开发板上操作) rm /usr/local/qt-4.6.2-arm/lib/fonts/* -f cp wenquanyi_120_50.qpf /usr/local/qt-4.6.2-arm/lib/fonts/ 3>修改PC上环境变量以便编译 export ARMQTDIR=/usr/local/qt-4.6.2-arm \ export PATH=$ARMQTDIR/bin:$PATH \ export MANPATH=$ARMQTDIR/man:$MANPATH \ export LD_LIBRARY_PATH=$ARMQTDIR/lib:$LD_LIBRARY_PATH \ qmake -v可以查看版本 QMake version 2.01a Using Qt version 4.6.2 in /usr/local/qt-4.6.2-arm/lib 4>写一个测试程序并交叉编译 #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel *label = new QLabel("Hello Qt!"); label->show(); return app.exec(); } 保存为hello.cpp 执行: qmake -project qmake hello.pro (如果有错误提示QMAKESPEC has not been set, so configuration cannot be deduced. 则export QMAKESPEC=/usr/local/qt-4.6.2-arm/mkspecs/qws/linux-arm-g++设置环境变量后, 再qmake hello.pro,否则执行下一步) make cp hello /home/profiles/2440/rootfs/sbin 拷贝程序到开发板 5>修改开发板ts配置文件 vi /usr/local/etc/ts.conf 去掉module_raw input前面的注释和空格并保存 运行一下ts校正程序 /usr/local/bin/ts_calibrate 6>设置环境变量,开发板上执行 export QTDIR=/usr/local/qt-4.6.2-arm export T_ROOT=/usr/local export PATH=$QTDIR/bin:$PATH export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb0 export TSLIB_TSDEVICE=/dev/input/event0 export TSLIB_PLUGINDIR=$T_ROOT/lib/ts export TSLIB_CONFFILE=$T_ROOT/etc/ts.conf export TSLIB_CALIBFILE=/etc/pointercal export QWS_MOUSE_PROTO=Tslib:/dev/input/event0 export LD_LIBRARY_PATH=$T_ROOT/lib:$QTDIR/lib (注意/dev/fb0是framebuffer设备结点,/dev/input/event0是触摸屏设备结点名称, 注意自己的开发板是否一致,包括交叉编译并安装qt的目录/usr/local/qt-4.6.2-arm, 触摸屏校验文件的位置/etc/pointercal,配置文件的位置$T_ROOT/etc/ts.conf) 7>运行hello程序 hello -qws 8>若需要开机即启动自己的qt程序,则需要修改启动脚本 vi etc/init.d/rcS (若脚本里有启动qtopia,如: /bin/qtopia & echo " " > /dev/tty1 echo "Starting Qtopia, please waiting..." > /dev/tty1 则注释这三句,在前面加上# #/bin/qtopia & #echo " " > /dev/tty1 #echo "Starting Qtopia, please waiting..." > /dev/tty1 ) 在文件最后加上 /bin/mypda & echo " " > /dev/tty1 echo "Starting my PDA..." > /dev/tty1 sleep 1 这样就会自动启动/bin目录下的mypda这个脚本。 建立这个脚本 vi /bin/mypda 输入 #!/bin/sh export QTDIR=/usr/local/qt-4.6.2-arm export T_ROOT=/usr/local export PATH=$QTDIR/bin:$PATH export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb0 export TSLIB_TSDEVICE=/dev/input/event0 export TSLIB_PLUGINDIR=$T_ROOT/lib/ts export TSLIB_CONFFILE=$T_ROOT/etc/ts.conf export TSLIB_CALIBFILE=/etc/pointercal export QWS_MOUSE_PROTO=Tslib:/dev/input/event0 export LD_LIBRARY_PATH=$T_ROOT/lib:$QTDIR/lib exec sbin/hello -qws 保存,chmod +x /bin/mypda,加执行权限 大功告成,reboot体验一下吧!