1. 程式人生 > >海思3536:交叉編譯Qt4.8.4

海思3536:交叉編譯Qt4.8.4

一、交叉編譯qt

1、下載Qt原始碼包qt-everywhere-opensource-src-4.8.4.tar.gz;

2、解壓Qt原始碼包tar -xvfzqt-everywhere-opensource-src-4.8.4.tar.gz

3、建立qmake.conf

3.1在qt-everywhere-opensource-src-4.8.4/mkspecs/qws/下建立linux-hisiv400-g++;

3.2將qt-everywhere-opensource-src-4.8.4/mkspecs/qws/linux-arm-g++/下內容拷貝到3.1新建的資料夾中;

3.3 修改qmake.conf,如下

   # 設定交叉編譯工具鏈:

   # 本專案使用的交叉編譯工具是 arm-hisiv400-linux-g++

   #

   QMAKE_CC                   = arm-hisiv400-linux-gcc

   QMAKE_CXX                 = arm-hisiv400-linux-g++

   QMAKE_LINK                = arm-hisiv400-linux-g++

   QMAKE_LINK_SHLIB    = arm-hisiv400-linux-g++ 

   QMAKE_AR                   = arm-hisiv400-linux-ar cqs

   QMAKE_OBJCOPY        =arm-hisiv400-linux-objcopy

  QMAKE_STRIP                     =arm-hisiv400-linux-strip

4、配置Qt編譯選項

4..1 編譯原始碼方式:

檢視嵌入式QTE命令:./configure –embedded –help

通過進行裁剪得到下邊配置引數:

進入Qt解壓目錄,執行如下命令(紅色字型:根據自己的平臺配置):

./configure -prefix /usr/local/Qt-4.8.4-arm -platform qws/linux-x86-g++-embedded arm -xplatform /qws/linux-hisiv400-g++

   -stl -qt-mouse-pc -release -no-fast-qt-gfx-transformed  -shared  -no-largefile   -no-system-proxies -no-exceptions-no-accessibility  -no-sql-QDB2-no-sql-QIBASE -no-sql-QMYSQL -no-sql-QOCI -no-sql-QODBC  -no-sql-QPSQL -no-sql-QSQLITE2-no-sql-QSQLITE -no-sql-QSYMSQL -no-sql-QTDS -no-armfpa -no-qt3support-no-xmlpatterns -no-multimedia -no-audio-backend -no-phonon  -no-phonon-backend -no-svg  -no-webkit -no-javascript-jit   -no-script -no-scripttools -no-declarative -no-declarative-debug -no-mmx -no-3dnow-no-sse -no-sse2 -qt-zlib  -qt-libpng-no-libmng -no-libjpeg -no-opengl -no-openssl -no-nis -no-cups -iconv  -pch -no-separate-debug-info -no-dbus -depths16,18,24,32 -little-endian  -no-glib  -nomake part -reduce-relocations   -no-gtkstyle -qt-freetype  -opensource

4.2 配置完畢輸出如下內容:

This is the Qt for Embedded Linux OpenSource Edition.

You are licensed to use this software underthe terms of

the Lesser GNU General Public License(LGPL) versions 2.1.

You are also licensed to use this softwareunder the terms of

the GNU General Public License (GPL)versions 3.

Type '3' to view the GNU General PublicLicense version 3.

Type 'L' to view the Lesser GNU GeneralPublic License version 2.1.

Type 'yes' to accept this license offer.

Type 'no' to decline this license offer.

Do you accept theterms of either license? Yes

5、make

6、sudo make intall      

/usr/local/Qt-4.8.4-arm中生成目標

二、配置目標板

1、將usr/local/Qt-4.8.4-arm中lib及plugins拷貝到目標板/usr/local/Qt-4.8.4-arm目錄下

2、在目標版的/etc/profile裡新增如下內容:

export QT_INSTALL_PATH=/usr/local/Qt-4.8.4-arm

exportLD_LIBRARY_PATH=/lib:/usr/lib:${QT_INSTALL_PATH}/lib:${LD_LIBRARY_PATH}

export QT_QWS_FONTDIR=${QT_INSTALL_PATH}/lib/fonts

exportQT_QWS_DISPLAY=linuxFB:/dev/fb0

注意:交叉編譯時安裝目錄和目標板上的qt庫存放目錄一致時(1、中兩個紅色的目錄一致),可不用設定上述環境變數。

3、source /etc/profile使環境變數立即生效。

4、配置/dev/fb0

4.1 將/dev/fb0設定為RGB8888模式(Qt需要在該模式下執行)

4.2 參考Hi3536_SDK_V2.0.4.0/mpp_single/sample/hifbsd/sample_hifb.c

4.3 使用分支4,compression模式:在執行ioctl函式後,掛起程式。提示:需要修改的位置有個註釋//opencompress;

4.4 重新編譯生成sample_hifb

三、測試執行

1、交叉編譯一個Qt demo,拷貝到目標板上

2、載入hifb.ko(可以使用load3536 -a,載入全部模組)

3、執行sample_hifb &(螢幕會成綠色)

4、執行Qt demo(加-qws選項)

5、螢幕出現demo介面,成功!