1. 程式人生 > >qt5.2交叉編譯移植到arm(s5pv210)

qt5.2交叉編譯移植到arm(s5pv210)

1、下載qt-everywhere-opensource-src-5.2.0.tar.xz原始碼,連結:http://download.qt.io/archive/qt/5.2/5.2.0/single/

2、解壓tar xJf tar xJf qt-everywhere-opensource-src-5.2.0.tar.xz

3、cd qt-everywhere-opensource-src-5.2.0/qtbase/mkspecs/linux-arm-gnueabi-g++/找到qmake.config,修改如下

#
# qmake configuration for building with arm-linux-gnueabi-g++
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental
QMAKE_INCREMENTAL_STYLE = sublib

#linuxfb: linux平臺下的framebuffer裝置

QT_QPA_DEFAULT_PLATFORM =linuxfb     #指定Qt執行平臺 EGLFS, LinuxFB, KMS, DirectFB, Wayland,                 
QMAKE_CFLAGS_RELEASE    += -O2 -march=armv7-a         #O2為優化選項,march指處理器架構,s5pv210的架構是armv7
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                = arm-linux-gcc -lts
QMAKE_CXX               = arm-linux-g++ -lts
QMAKE_LINK              = arm-linux-g++ -lts
QMAKE_LINK_SHLIB        = arm-linux-g++ -lts

# modifications to linux.conf
QMAKE_AR                = arm-linux-ar cqs
QMAKE_OBJCOPY           = arm-linux-objcopy
QMAKE_NM                = arm-linux-nm -P
QMAKE_STRIP             = arm-linux-strip
load(qt_config)

4、切換到頂層目錄並新建資料夾tmp

cd qt-everywhere-opensource-src-5.2.0/

mkdir tmp

5、編寫自動化配置指令碼automake.sh,內容如下:

#!/bin/bash

TSLIBINC="/home/mark/work/tool/tslib_ok/tslib-1.16/tmp/include"

TSLIBLIB="/home/mark/work/tool/tslib_ok/tslib-1.16/tmp/lib"

./configure -prefix /home/mark/work/tool/qt/qt-5.6-arm \
-xplatform linux-arm-gnueabi-g++ \
-opensource -release \
-confirm-license \
-shared -qt-zlib \
-qt-libjpeg \
-qreal float \
-qt-libpng \
-tslib \
-alsa \
-no-gif \
-no-iconv \
-no-opengl \
-no-cups \
-no-glib \
-no-dbus \
-no-rpath \
-no-sse2 \
-no-sse3 \
-no-sse4.1 \
-no-sse4.2 \
-no-avx \
-no-xcursor -no-xfixes -no-xrandr -no-xrender \
-no-separate-debug-info \
-nomake tools \
-nomake examples \
-I ${TSLIBINC} \
-L ${TSLIBLIB}

下面根據自己情況修改

-prefix /home/mark/work/tool/qt/qt-5.6-arm: 表面qt編譯後安裝到當前目錄的tmp目錄下

-tslib :表示加入觸控式螢幕庫

-I  $(TSLIBINC)  :指定tslib標頭檔案目錄

-L $(TSLIBLIB):指定tslib庫檔案目錄

automake.sh下載連結附檔案末尾

6、./automake.sh && make -j4

7、make install

8、將安裝好的交叉編譯庫和標頭檔案儲存到根檔案系統

 cp * /home/mark/work/nfs/qt   

修改根檔案系統的/etc/profile

/bin/hostname TQ210
HOSTNAME='/bin/hostname'
PS1='[\h \w]\$'
export PS1 HOSTNAME

export TSLIB_ROOT=/qt/tslib
export TSLIB_TSDEVICE=/dev/event0
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CONSOLEDEVICE=none
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointeral


#export QWS_MOUSE_PROTO=tslib:/dev/event0
#export QWS_SIZE=800*400
#export QTDIR=/qt/qt-5.6-arm
#export QT_QPA_FONTDIR=$QTDIR/lib/fonts/
#export LD_LIBRARY_PATH=/usr/lib:/lib:$TSLIB_ROOT/lib:$QTDIR/lib:$LD_LIBRARY_PATH
#export QT_PLUGIN_PATH=$QTDIR/plugins/

#QT目錄
export QTDIR=/qt/qt-5.6-arm
#庫檔案目錄
export LD_LIBRARY_PATH=$TSLIB_ROOT/lib:$QTDIR/lib:/usr/lib:/lib:$LD_LIBRARY_PATH
#觸控式螢幕庫
export QT_QPA_GENERIC_PLUGINS=tslib
#字型
export QT_QPA_FONTDIR=$QTDIR/lib/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
#觸控式螢幕檔案,長寬,終端
export 
QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=800x480:mmSize=800x480:offset=0x0:tty=/dev/tty0
export QT_QPA_FB_TSLIB=1
#觸控式螢幕庫
export LD_PRELOAD=$TSLIB_ROOT/lib/libts.so

指定QT執行環境變數。

automake.sh, qmake.sh, etc/profile下載地址:https://pan.baidu.com/s/1ls6X6MaMpsM4YQ2C1sCpjg