目標機上的QT環境構建
(因爲是後期整理的,所以圖文不太相符)
首先要下載qteverywhere,下載鏈接如下,失效的話自行百度下載,版本是5.5.1。
鏈接:https://pan.baidu.com/s/1f4P5q83eLB2V_-Ef6P-C2g 密碼:3t18
把qt-everywhere解壓到一個你喜歡的文件夾下吧。
新建兩個文件夾mkdirbuild;mkdirinstall
解壓一下:tarxzfv qt-everywhere-opensource-src-5.5.1.tar.gz
進入qt-everywhere-opensource-src-5.5.1文件夾
指定安裝路徑:
exportZYNQ_QT_BUILD=/home/xilinx/qt_zynq/build
exportZYNQ_QT_INSTALL=/home/xilinx/qt_zynq/install
exportPATH=$ZYNQ_QT_INSTALL/bin:$PATH
新建qmake.conf文件:
mkdir -pqtbase/mkspecs/arm-xilinx-linux-gnueabi-g++
vimqtbase/mkspecs/arm-xilinx-linux-gnueabi-g++/qmake.conf
把下面的代碼複製進去:
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE= sublib
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications tog++.conf
QMAKE_CC = arm-linux-gnueabihf-gcc -lrt
QMAKE_CXX = arm-linux-gnueabihf-g++ -lrt
QMAKE_LINK = arm-linux-gnueabihf-g++ -lrt
QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++ -lrt
# modifications tolinux.conf
QMAKE_AR = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
QMAKE_NM = arm-linux-gnueabihf-nm -P
QMAKE_STRIP = arm-linux-gnueabihf-strip
load(qt_config)
新建qplatformdefs.h文件:
vim qtbase/mkspecs/arm-xilinx-linux-gnueabi-g++/qplatformdefs.h
把下面的代碼複製進去:
#include" ../linux-g++/qplatformdefs.h"
新建qtsh.sh文件:
vim qtsh.sh
把下面的代碼複製進去:
./configure-xplatform arm-xilinx-linux-gnueabi-g++ \
-opensource \
-confirm-license \
-nomake examples \
-skipqtquickcontrols \
-skip qtwebkit \
-skip qtwebchannel\
-skip qtactiveqt \
-skipqtandroidextras \
-skip qtdeclarative\
-skipqtimageformats \
-skip qtmacextras \
-skip qtserialport\
-skip qtx11extras \
-skip qtxmlpatterns\
-skipqtconnectivity \
-skip qtdoc \
-skip qtenginio \
-skipqtgraphicaleffects \
-skip qtlocation \
-skip qtmultimedia\
-skip qtquick1 \
-skip qtsensors \
-skip qttools \
-skipqttranslations \
-skip qtwayland \
-skip qtwebchannel\
-skip qtwebengine \
-skipqtwebkit-examples \
-skip qtwebsockets\
-skip qtwinextras \
-verbose \
-no-gif \
-no-libjpeg \
-no-mtdev \
-no-sql-db2 \
-no-sql-ibase \
-no-sql-mysql \
-no-xcb \
-qt-freetype \
-no-fontconfig \
-no-harfbuzz \
-no-xinput2 \
-no-xcb-xlib \
-no-pulseaudio \
-no-alsa \
-no-gtkstyle \
-no-nis \
-no-cups \
-no-iconv \
-no-icu \
-no-eglfs \
-no-openssl \
-prefix$ZYNQ_QT_INSTALL
指定交叉編譯器:
exportCROSS_COMPILE= arm-linux-gnueabihf-
執行指令“sh./qtsh.sh”。
平臺爲ubuntu16.04。其它平臺不保證能成功。
配置完成後,就來安裝吧。輸入:make&& make install
等待大約半個小時,就完成了。
完成後,打開qtcreator,在root用戶下打開,就不會出現我下面出現的錯誤了。
打開qtcreator
tools->options
打開設置選項。
添加GCC編譯器
名字爲
GCC(/home/xilinx/cross_compile/gcc-linaro-5.5.0-2017.10-i686_arm-linux-gnueabihf/bin)
添加編譯器路徑
/home/xilinx/cross_compile/gcc-linaro-5.5.0-2017.10-i686_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
(按文字來,圖文不太相符,下同)
點aplly應用。
轉到QTversions標籤
添加qmake文件。
我的路徑在:/home/zynq/qt_zynq/install/bin/qmake
那是install目錄中的。
點apply應用一下
轉到kits標籤
名稱自己喜歡吧,設備類型選androiddevice,編譯器選在compilers標籤中設置的,QTversion選5.5.1吧,在QTversion標籤上設置的,debug選systemgdb at /usr/bin/gdb,最後apply,如下圖所示。
好了,到這裏,開發環境算是搭好了。
做好以後,新建工程會有這樣的選項:
創建或者打開之前創建過的hello程序測試一下。
在剛的那個helloproject中的右欄打開project標籤
點addkit,選擇剛創建的kit,我這裏是QTE。
不知道爲什麼目錄會是紅色的,而且終端上也出現了一些提示信息。如果出問題再解決吧。
後來發現是沒有創建這個目錄所以顯示紅色。
下面重新編譯一下。(這是後來放的圖,重新編譯後紅色就沒有了)
看起來好像也沒什麼錯誤。說明編譯還是成功的。
同樣也可以在這裏切換編譯環境:
從編譯信息可以看出,編譯的文件在原來hello工程的文件夾裏面,會有一個專門的QTE的kit的文件夾裏存放。
下面把hello文件發送到開發板上運行就可以了。
記住,QT的編譯器是arm-linux-gnueabihf-g++,不要用arm-xilinx-linux-gnueabi-這個編譯器,不然無法在xillinux中運行。
運行結果圖:
至此,qt環境就構建完成了。