簡單記錄過程:
1,下載下傳qt-everywhere-opensource-src-5.6.3源碼,位址:http://download.qt.io/archive/qt/
2,下載下傳arm-linux-4.4.3的交叉編譯器,位址:https://download.csdn.net/download/immortal018/10421132
3,設定編譯器或者說平台。通過xplatform參數指定編譯器,xplatform後面跟的參數實際上即是
qtbase/mkspec
下的檔案夾的名字,修改該檔案夾下的
qmake.conf
,修改後的内容如下所示:(path為自己存放交叉編譯器4.4.3的具體路徑)
#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS_RELEASE +=-O2 -march=armv7-a
QMAKE_CXXFLAGS_RELEASE +=-O2 -march=armv7-a
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = /path/4.4.3/bin/arm-none-linux-gnueabi-gcc
QMAKE_CXX = /path/4.4.3/bin/arm-none-linux-gnueabi-g++
QMAKE_LINK = /path/4.4.3/bin/arm-none-linux-gnueabi-g++
QMAKE_LINK_SHLIB = /path/4.4.3/bin/arm-none-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = /path/4.4.3/bin/arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /path/4.4.3/bin/arm-none-linux-gnueabi-objcopy
QMAKE_NM = /path/4.4.3/bin/arm-none-linux-gnueabi-nm -P
QMAKE_STRIP = /path/4.4.3/bin/arm-none-linux-gnueabi-strip
load(qt_config)
4,找到源碼目錄下的
qt.pro
,屏蔽掉下面兩句話:
addModule(qt3d, qtdeclarative qtimageformats)
addModule(qtcanvas3d, qtdeclarative)
5,建立shell腳本,進行子產品裁剪,編譯:(具體的參數含義可以再終端輸入 ./configure --help 檢視釋意)
--prefix 是相對于這個目錄來安裝的,也就是說 make install 後,qt的庫安裝到了
/opt
目錄下
#bin/bash
echo yes | ./configure -opensource -release --prefix=/opt/QtE5.6 \
-qt-libpng -qt-zlib -qt-libjpeg -plugin-sql-sqlite -widgets -qt-sql-sqlite -make libs \
-silent -xplatform linux-arm-gnueabi-g++ -nomake tools -nomake examples \
-no-xcb -mtdev -xinput2 -strip -linuxfb -confirm-license -qt-freetype -fontconfig \
-no-cups -no-iconv -no-qml-debug -no-dbus -no-largefile -no-opengl \
-nomake tests -no-openvg -no-egl -no-openssl -no-accessibility -tslib \
-no-sse2 -no-c++11 -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender
6,運作上面的 shell 腳本,将編譯生成的 QtE5.6 拷貝到目标闆上。這裡放到
/usr
目錄下,并在目标闆的/etc/profile中配置Qt5的環境變量,并添加電容觸摸屏的支援,如下所示:
export QTDIR=/usr/QtE
export PATH=$QTDIR:$PATH
export QT_QPA_FONTDIR=$QTDIR/lib/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:rotation=180
#由于Qt5本身就支援多點觸摸,是以直接使用Qt提供的evdevtouch插件庫,無需另外再額外編譯tslib
export QT_QPA_GENERIC_PLUGINS=evdevtouch:/dev/input/event2
export LD_LIBRARY_PATH=/lib:$QTDIR/lib:$QTDIR/x11/lib:$QTDIR/tslib:$QTDIR/mtdev/lib
7,至此,觸摸屏就可以使用了,直接執行
./app
即可,無需其他參數