Qt4.8.5移植


這兩天搞了Qt移植 因為不小心 耽誤了挺多時間 但是也比較好的掌握了   現在記錄一下

 

准備工具: tslib-1.16    qt-everywhere-opensource-src-4.8.5.tar     qtcreator

下載路徑:

    tslib-1.16下載:                                                     https://github.com/kergoth/tslib/releases/download/1.16/tslib-1.16.tar.bz2

    Qtqt-everywhere-opensource-src-4.8.5.tar下載:  http://download.qt.io/archive/qt/

    Qt creator下載:                                                      http://download.qt.io/archive/qtcreator/

 

tslib 的移植


 解壓 tslib.


進入 tslib 源代碼目錄
    創建 out 目錄,或者其他的目錄名字用於安裝的            注意: 這個文件名很重要      后面都要用到
運行 autogen.sh
    ./autogen.sh
寫一個配置的腳本
   mygen.sh

#!/bin/sh
./configure \
--prefix=/xxxx \
--host=arm-linux-gnueabihf

xxx為想要安裝的路徑


給這個配置腳本加一個權限


   chmod +x mygen.sh

運行這個腳本

    ./mygen.sh

編譯


   make && make install


生成的庫在 out 文件夾下面

bin etc include lib share

Qt 交叉編譯

  • 將 Qt 源碼放入 Ubuntu 虛擬機,並解壓。
  tar -xvf qt-everywhere-opensource-src-4.8.5.tar.gz
  cd qt-everywhere-opensource-src-4.8.5/
  • 復制一份配置文件
  cp mkspecs/qws/linux-arm-gnueabi-g++/  mkspecs/qws/linux-arm-gnueabihf-g++/ -rf
  • 修改該配置文件 mkspecs/qws/linux-arm-gnueabihf-g++/qmake.conf
#
# qmake configuration for building with arm-none-linux-gnueabi-g++
#

include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
include(../../common/qws.conf)

# modifications to g++.conf
QMAKE_CC                = arm-linux-gnueabihf-gcc
QMAKE_CXX               = arm-linux-gnueabihf-g++
QMAKE_LINK              = arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB        = arm-linux-gnueabihf-g++

# modifications to linux.conf
QMAKE_AR                = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY           = arm-linux-gnueabihf-objcopy
QMAKE_STRIP             = arm-linux-gnueabihf-strip


QMAKE_INCDIR            = /tslib安裝的而絕對路徑/include
QMAKE_LIBDIR            = /tslib安裝的而絕對路徑/lib

load(qt_config)
# 上面這兩條是 tslib 庫的位置 load(qt_config)

 

 注意:一定要看清楚里面  要一樣的才行  arm-linux-gnueabihf-xxxx


在 mkspecs/common/linux.conf 中 QMAKE_LIBS_THREAD    這一行加入 -lts
  QMAKE_LIBS_THREAD     = -lpthread -lts

 

 

  • 家目錄創建一個 qtlib 目錄
  mkdir ~/qtlib
  • 在 Qt4.8.5 源碼目錄創建 config.sh 配置腳本  編輯一下內容
#!/bin/sh 
    ./configure   \
		-opensource \
		-prefix  /想要安裝的路徑   \
		-confirm-license \
		-release \
		-shared \
		-embedded arm \
		-force-pkg-config \
		-xplatform qws/linux-arm-gnueabihf-g++ \
		-depths 16,18,24,32 \
		-fast \
		-optimized-qmake \
		-pch \
		-qt-sql-sqlite \
		-qt-libjpeg \
		-qt-zlib \
		-qt-libpng \
		-qt-freetype \
		-little-endian -host-little-endian \
		-no-qt3support \
		-qt-libtiff -qt-libmng \
		-make translations \
		-qt-gfx-linuxfb -qt-gfx-transformed -qt-gfx-multiscreen \
		-no-gfx-vnc -no-gfx-qvfb -qt-kbd-linuxinput \
		-no-kbd-qvfb -armfpa  \
		-no-mouse-qvfb \
		-no-opengl \
		-no-mmx -no-sse -no-sse2 \
		-no-3dnow \
		-no-openssl \
		-webkit \
		-no-qvfb \
		-no-phonon \
		-no-nis \
		-no-opengl \
		-no-cups \
		-no-glib \
		-no-xcursor -no-xfixes -no-xrandr -no-xrender \
		-no-separate-debug-info \
		-nomake examples -make tools -nomake docs \
		-qt-mouse-tslib -DQT_QLOCALE_USES_FCVT \
		-I/xxx安裝tslib的時候創建的文件夾的絕對路徑 里面有include文件夾xxx\include \
		-L/xxx安裝tslib的時候創建的文件夾的絕對路徑 里面有lib文件夾xxx/lib \ 
		-no-pch

  

  • 給它加一個執行權限,並執行
  chmod +x config.sh && ./config.sh
  • 執行編譯並安裝
  make -j4 && make install

編譯的時候最終會在atlib文件夾下生成如下文件
  ls ~/qtlib/  bin imports include lib mkspecs phrasebooks plugins 

到這里qt交叉編譯已經安裝完成

Qtcreator 安裝及環境配置

  • 下載完之后,將這個文件放到 Ubuntu 虛擬機里面,加一個執行權限,並運行。
  chmod +x qt-creator-linux-x86_64-opensource-2.8.1.run && ./qt-creator-linux-x86_64-opensource-2.8.1.run
  • 安裝完畢打開 qtcreator qtcreator

  • 配置交叉編譯器

  • 進入 Tools->Options QCompiler

  • 配置 qmake。

    • 進入 Tools->Options qmake
  • 配置 qkit

    • 進入 Tools->Options qkit
  • 配置完畢,選擇 Apply, OK

  • 打開一個例程,進行編譯,KIt Selection 的時候要選擇 arm2

 

       以上參考:https://www.cnblogs.com/chenfulin5/p/6958560.html

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM