基於Arm(OMAP3530)平台的Linux上編譯QT4.6.2

來源:互聯網
上載者:User

文章首發:http://user.qzone.qq.com/276546441/gift?target=send_5th&senduin=58720861

 

 

環境:ubuntu 8.04

硬碟空間:40G

QT代碼:4.6.2 (:http://qt.nokia.com/downloads)

步驟:

  A. Embedded版

  1、修改路徑為[qt-install-dir]/mkspecs/qws/linux-arm-g++/qmake.conf的檔案:

     #<br />    # qmake configuration for building with arm-linux-g++<br />    #</p><p>    include(../../common/g++.conf)<br />    include(../../common/linux.conf)<br />    include(../../common/qws.conf)</p><p>    # 修改g++裡的宏定義<br />    #設定使用ARM進階特性的編譯標誌<br />    QMAKE_CFLAGS_RELEASE = -O3 -march=armv7-a<br />    -mtune=cortex-a8<br />    -mfpu=neon<br />    -mfloat-abi=softfp<br />    QMAKE_CXXFLAGS_RELEASE = -O3 -march=armv7-a<br />    -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp</p><p>    # 設定交叉編譯工具鏈<br />    # 本項目中使用的交叉編譯工具為<br />    # http://www.codesourcery.com/sgpp/lite/arm<br />    #<br />    QMAKE_CC = arm-none-linux-gnueabi-gcc<br />    QMAKE_CXX = arm-none-linux-gnueabi-g++<br />    QMAKE_LINK = arm-none-linux-gnueabi-g++<br />    QMAKE_LINK_SHLIB = arm-none-linux-gnueabi-g++</p><p>    # 修改linux.conf中的宏定義<br />    QMAKE_AR = arm-none-linux-gnueabi-ar cqs<br />    QMAKE_OBJCOPY = arm-none-linux-gnueabi-objcopy<br />    QMAKE_STRIP = arm-none-linux-gnueabi-strip</p><p>    load(qt_config)  
     2、配置QT腳編譯選項

  控制台進入QT代碼根目錄,執行./configure -prefix <PATH_TO_NFS> -embedded arm -platform /qws/linux-x86-g++
    -xplatform /qws/linux-omap3-g++ -depths 16,24,32 -no-mmx
    -no-3dnow -no-sse -no-sse2 -
    no-glib -no-cups
    -no-largefile -no-accessibility -no-openssl -
    no-gtkstyle -qt-mouse-pc -qt-mouse-linuxtp
    -qt-mouse-linuxinput -plugin-mouse-linuxtp -plugin-mouse-pc -fast

    註:1,這些配置選項為TI的參考配置,自己可以隨意增減來測試效果,
      2,參數的具體作用可以通過./configure --help來查看
      3, <PATH_TO_NFS>是QT被安裝的到板子上的全路徑,用來儲存編譯產生的各種檔案。

  3、排除錯誤的方法

  配置出錯時,可以到tmp目錄下,進入長得像的配置QT的臨時檔案夾,找config.log檔案,此檔案中有出錯的詳細資料。如果沒出錯,執行make 與make install,都沒有錯誤,則編譯成功,把<PATH_TO_NFS>中的檔案同名同目錄拷貝到板子上的SD卡中便可以使用QT了。

  4、版本說明

  Embedded版本的QT,自己實現了X-Server與X-Client,故不能與已有的案頭環境共存,在OpenEmbedded的開源項目中,許多可以使用於X11環境中的工具,在QT的Embedded環境中暫時沒發現能使用,要想使用它們只能把QT編譯成基ARM體系的X11版本,具體步驟參考B。

  B. X11版[2]

  1、編譯angstrom

  我們板子中使用的案頭環境為angstrom, 編譯QT X11需要把此案頭環境編譯出來,按照[5]提供的步驟進行angstrom的編譯,其中MACHINE ?= "beagleboard" bitbake base-image ; bitbake console-image x11-image後增加beagleboard-demo-image,可能直接bitbake beagleboard-demo-image就可以。網速快的話十幾個小時應該可以完成編譯過程。

 

  2、設定Scratchbox2的環境

  先安裝Scratchbox2,執行sudo apt-get install help2man texi2html texinfo 然後執行sudo apt-get install Scratchbox2,便可安裝成功;安裝成功後,修改/usr/bin/sb2-build-libtool中的配置值

  - ./configure –prefix=$HOME/.scratchbox2/$TARGET –build=$(uname -m)-unknown-linux-gnu<br />  + ./configure –host=x86 –prefix=$HOME/.scratchbox2/$TARGET –build=$(uname -m)-unknown-linux-gnu
  sudo dpkg-reconfigure dash 選擇否,修改/bin/sh指向為安全指向,否則sb2-init執行不了。

  在 /etc/sysctl.conf中設定vm.mmap_min_addr = 0,設定完成後需要重啟,否則sb2-init執行不了。

  在~/OE/angstrom-dev/staging/armv7a-angstrom-linux-gnueabi目錄中執行sb2-init -c /usr/bin/qemu-arm angstrom-beagle ~/OE/angstrom-dev/cross/armv7a/bin/arm-angstrom-linux-gnueabi-gcc 。最後一個參數為編譯器工具鏈路徑,可以使用/opt/codesourcery/arm-none-linux-gnueabi/arm-2007q3/bin/arm-angstrom-linux-gnueabi-gcc(這個是我機已經配置好交叉編譯的工具路徑)    

  3、編譯QT X11
  修改/qws/linux-arm-g++/qmake.conf為

    #<br />    # qmake configuration for linux-g++<br />    #</p><p>    MAKEFILE_GENERATOR = UNIX<br />    TEMPLATE = app<br />    CONFIG += qt warn_on release incremental link_prl<br />    QT += core gui<br />    QMAKE_INCREMENTAL_STYLE = sublib</p><p>    include(../../common/g++.conf)<br />    include(../../common/linux.conf)<br />    # modifications to g++.conf</p><p>    QMAKE_CC = sb2 gcc<br />    QMAKE_CXX = sb2 g++<br />    QMAKE_LINK = sb2 g++<br />    QMAKE_LINK_SHLIB = sb2 g++</p><p>    # modifications to linux.conf<br />    QMAKE_AR = sb2 ar cqs<br />    QMAKE_OBJCOPY = sb2 objcopy<br />    QMAKE_STRIP = sb2 strip<br />    load(qt_config)

     修改QT根目錄下的configure指令檔,其中行號不正確,具體行號位置以

    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG –exists fontconfig 2>/dev/null; then<br />    QT_CFLAGS_FONTCONFIG=`$PKG_CONFIG –cflags fontconfig 2>/dev/null`<br />    QT_LIBS_FONTCONFIG=`$PKG_CONFIG –libs fontconfig 2>/dev/null`
  的位置為準,此處主要用於配置字型檔的標頭檔路徑。

    diff –git a/configure b/configure<br />    index 3f3e55a..54de96b 100755<br />    ---a/configure<br />    +++ b/configure<br />    @@ -5115,6 +5115,10 @@ if [ "$PLATFORM_X11" = "yes" ]; then<br />    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG –exists fontconfig 2>/dev/null; then<br />    QT_CFLAGS_FONTCONFIG=`$PKG_CONFIG –cflags fontconfig 2>/dev/null`<br />    QT_LIBS_FONTCONFIG=`$PKG_CONFIG –libs fontconfig 2>/dev/null`<br />    + if $PKG_CONFIG –exists freetype2 2>/dev/null; then<br />    + QT_CFLAGS_FONTCONFIG="$QT_CFLAGS_FONTCONFIG `$PKG_CONFIG –cflags freetype2 2>/dev/null`"<br />    + QT_LIBS_FONTCONFIG="$QT_LIBS_FONTCONFIG `$PKG_CONFIG –libs freetype2 2>/dev/null`"<br />    + fi<br />    else<br />    QT_CFLAGS_FONTCONFIG=<br />    QT_LIBS_FONTCONFIG="-lfreetype -lfontconfig"

  然後執行 ./configure -prefix <PATH_TO_NFS> -arch arm -xplatform pws/linux-arm-g++ -force-pkg-config 便可以完成配置。最後執行make與make install。執行make時會出現 global/qlibraryinfo.cpp:490: error: expected primary-expression before '/' token的錯誤,修改出錯位置的ELF_INTERPRETER,為"/lib/ld-linux.so.2"(此值可以從Makefile中的-DELF_INTERPRETER=得到)即可。

參考:

  1. http://processors.wiki.ti.com/index.php/Building_Qt

  2. http://labs.trolltech.com/blogs/2009/11/20/building-qt-to-make-use-of-the-beagle-boards-sgx-gpu/

  3. http://labs.trolltech.com/blogs/2010/02/05/qtx11-bring-up-on-tegra2-with-full-opengl-es-2-support

  4. http://labs.trolltech.com/blogs/2009/09/10/cross-compiling-qtx11/

  5. http://www.angstrom-distribution.org/building-angstrom

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.