从零开始移植QT4.8.5之三--linux下交叉编译QT运行库

这篇文章要实现的目标是在linux下交叉编译QT在嵌入式设备OK6410的运行库,最终在OK6410上运行QT演示程序。

1、触摸屏库文件安装tslib

首先如果嵌入式设备上有触摸屏,需要先移植tslib,这个不是本次的重点,所以我们就直接搭建编译的时候需要的tslib库,因为飞凌官方已经提供编译好了的库文件,所以之需要解压把库文件放到对应的位置就可以了。

编译好的tslib文件下载:http://download.csdn.net/detail/andylauren/9583536

解压到准备好的目录,这个目录需要记住,后面在编译QT的时候会用到,我的路径是/home/linux/arm/tslib目录下。

2、交叉编译qt-everywhere-opensource-src

需要在上一篇文章中的压缩包qt-everywhere-opensource-src-4.8.5.tar.gz,这里需要重新解压,因为如果已经configure过的会生成makefile文件,qt的configure会检测文件夹中是否有makefile,即使使用make clean也无法完全删除配置文件,在编译的时候可能会产生各种各样的路径、编译库不一致的错误,所以最好的方法就是每次编译之前都从新解压。

tar zxvf xxx.tar.gz

解压之后跳进解压后的文件夹

输入如下命令

echo yes | ./configure -opensource -embedded arm -xplatform qws/linux-arm-g++  -no-webkit -qt-libtiff -qt-libmng  -qt-mouse-tslib -qt-mouse-pc -no-mouse-linuxtp -prefix /home/linux/arm/qt-4.8.5-arm -I /home/linux/arm/tslib/include -L /home/linux/arm/tslib/lib

这里说明几个重要的设置

-prefix /home/linux/arm/qt-4.8.5-arm 这个是编译好的文件的目录,这个目录很重要,因为在开发板上也要将库文件放在这个目录中,所以需要谨慎选择。

-I /home/linux/arm/tslib/include          这个是刚刚解压好的tslib库的路径下的include

-L /home/linux/arm/tslib/lib                  这个是刚刚解压好的tslib库的路径下的lib

这几个需要根据自己的需求修改。

然后等着configure完成之后就可以经典的make&&make install

没有意外的话就会在/home/linux/arm/qt-4.8.5-arm路径下生成编译好的库文件

3、提取开发板需要的库文件

提取文件写了一个脚本,之需要其中的文件路径即可。下载地址:http://download.csdn.net/detail/andylauren/9583815

#!/bin/bash

TARGET_DIR=$PWD
cd /
list=`cat << EOF
home/linux/arm/qt-4.8.5-arm/examples/widgets/wiggly/wiggly
home/linux/arm/qt-4.8.5-arm/examples/painting/concentriccircles/concentriccircles
home/linux/arm/qt-4.8.5-arm/lib/libQtSql.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtXml.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtSvg.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtSql.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQtScript.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQtXml.so
home/linux/arm/qt-4.8.5-arm/lib/libQtMultimedia.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtScriptTools.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQtGui.so
home/linux/arm/qt-4.8.5-arm/lib/libQtSql.so
home/linux/arm/qt-4.8.5-arm/lib/libQtGui.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtXml.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtCore.so
home/linux/arm/qt-4.8.5-arm/lib/libQtGui.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQt3Support.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQtTest.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtCore.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/fonts/unifont_160_50.qpf
home/linux/arm/qt-4.8.5-arm/lib/libQtSvg.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtNetwork.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQt3Support.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtScript.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtScriptTools.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtNetwork.so
home/linux/arm/qt-4.8.5-arm/lib/libQtScript.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtNetwork.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtTest.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtSql.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtMultimedia.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQtTest.so
home/linux/arm/qt-4.8.5-arm/lib/libQt3Support.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtTest.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQtCore.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtScriptTools.so
home/linux/arm/qt-4.8.5-arm/lib/libQtMultimedia.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQtSvg.so
home/linux/arm/qt-4.8.5-arm/lib/libQtXml.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQtCore.so.4
home/linux/arm/qt-4.8.5-arm/lib/libQtScriptTools.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtNetwork.so.4.8.5
home/linux/arm/qt-4.8.5-arm/lib/libQtMultimedia.so
home/linux/arm/qt-4.8.5-arm/lib/libQtScript.so
home/linux/arm/qt-4.8.5-arm/lib/libQtGui.so.4.8
home/linux/arm/qt-4.8.5-arm/lib/libQt3Support.so
home/linux/arm/qt-4.8.5-arm/lib/libQtSvg.so.4
home/linux/arm/qt-4.8.5-arm/plugins/sqldrivers/libqsqlite.so
home/linux/arm/qt-4.8.5-arm/plugins/accessible/libqtaccessiblewidgets.so
home/linux/arm/qt-4.8.5-arm/plugins/accessible/libqtaccessiblecompatwidgets.so
home/linux/arm/qt-4.8.5-arm/plugins/iconengines/libqsvgicon.so
home/linux/arm/qt-4.8.5-arm/plugins/imageformats/libqico.so
home/linux/arm/qt-4.8.5-arm/plugins/imageformats/libqsvg.so
home/linux/arm/qt-4.8.5-arm/plugins/imageformats/libqtiff.so
home/linux/arm/qt-4.8.5-arm/plugins/imageformats/libqjpeg.so
home/linux/arm/qt-4.8.5-arm/plugins/imageformats/libqmng.so
home/linux/arm/qt-4.8.5-arm/plugins/imageformats/libqgif.so
home/linux/arm/qt-4.8.5-arm/demos/deform/deform
home/linux/arm/qt-4.8.5-arm/demos/deform/pathdeform.html
home/linux/arm/qt-4.8.5-arm/demos/embedded/embeddedsvgviewer/spheres.svg
home/linux/arm/qt-4.8.5-arm/demos/embedded/embeddedsvgviewer/embeddedsvgviewer
home/linux/arm/qt-4.8.5-arm/demos/embedded/embeddedsvgviewer/shapes.svg
home/linux/arm/qt-4.8.5-arm/demos/embedded/embeddedsvgviewer/files/default.svg
home/linux/arm/qt-4.8.5-arm/demos/embedded/embeddedsvgviewer/files/v-slider-handle.svg
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/desktopservices_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/deform.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/raycasting.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/digiflip.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/styledemo.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/styledemo_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/mediaplayer.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/weatherinfo.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/concentriccircles.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/context2d_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/wiggly.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/lightmaps.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/elasticnodes.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/wiggly_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/ftp_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/anomaly_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/flickable.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/softkeys_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/screenshots/pathstroke.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/slides/demo_4.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/slides/demo_1.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/slides/demo_2.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/slides/demo_6.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/slides/demo_3.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/slides/demo_5.png
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/fluidlauncher
home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher/config.xml
home/linux/arm/qt-4.8.5-arm/demos/embedded/styledemo/styledemo
home/linux/arm/qt-4.8.5-arm/demos/pathstroke/pathstroke.html
home/linux/arm/qt-4.8.5-arm/demos/pathstroke/pathstroke
EOF
`
tar cfvz $TARGET_DIR/target-qte-4.8.5.tgz  $list

根据自己的需要修改home/linux/arm/qt-4.8.5-arm路径,如果QT的版本改变可以根据自己需要修改其中对应的版本号,4.8.5和4.8,其他的内容基本不需要改变。

然后在任何路径下运行这个脚本就可以。完成后在当前目录中会生成target-qte-4.8.5.tgz文件,我生成的文件在下面下载:http://download.csdn.net/detail/andylauren/9583545

之后把target-qte-4.8.5.tgz文件拷贝到开发板的根目录下,然后解压就可以了,之后就会在开发板的/home/linux/arm/qt-4.8.5-arm目录下会有QT库文件了。

到这个时候就可以在开发板上运行QT程序了,下面我们提供一个QT演示程序的脚本文件。

4、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=/home/linux/arm/qt-4.8.5-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 /home/linux/arm/qt-4.8.5-arm/demos/embedded/fluidlauncher
./fluidlauncher -qws

这个脚本只能在OK6410开发板4.3寸屏幕上运行,具体的内容请读者自己阅读,下一篇文章我们会一起自己写一个QT程序运行起来。那个时候我们来对自己的程序一些环境配置具体的讲解。










你可能感兴趣的:(嵌入式系统移植)