從零開始移植QT4.8.5之三--linux下交叉編譯QT執行庫

andylauren發表於2016-07-22

這篇文章要實現的目標是在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程式執行起來。那個時候我們來對自己的程式一些環境配置具體的講解。










相關文章