Qt4.7 嵌入式環境搭建之源碼編譯和安裝

來源:互聯網
上載者:User

 

首先從官網下載QT的嵌入式版,注意官網上的嵌入式版和linux版都是199M,其實他們在官網上的位置不一樣,

Qt libraries 4.7.0 for embedded Linux (199 MB)

http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.0.tar.gz

Qt libraries 4.7.0 for Linux/X11(199 MB)

http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.0.tar.gz

其實下載下來是一樣(看他們的下載路徑都是一樣的)的,。下載下來的檔案名稱為: qt-everywhere-opensource-src-4.7.0.tar.gz

解壓

tar zxvf   qt-everywhere-opensource-src-4.7.0.tar.gz

把解壓後的檔案再複製兩份(一共三份),分別取名為pc; x86; arm;然後開始分別編譯:

1.編譯PC,  

cd pc

這一步可能出錯:1

此完整出錯資訊是在./configure階段

Basic XLib functionality test failed! 

You might need to modify the include and library search paths by editing 

QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /home/zhu/Qt/qt-x11-opensource-src-4.5.2/mkspecs/linux-g++

進config.test /x11/xlib 執行make命令,看出錯資訊

g++ -Wl,-O1 -o xlib xlib.o    -L/usr/X11R6/lib -lXext -lX11 -lm

/usr/bin/ld: cannot find -lXext

可以看到,g++在/usr/X11R6/lib下,找不到libXext.so

其原因就在於需要安裝libX11的開發包,根據自己的系統特點,安裝 libX11-dev   libXext-dev   libXtst-dev

可能出錯2:

/usr/bin/ld: cannot find -lXrender

說明還少一個包:安裝    libxrender-dev 

sudo apt-get install cutecom

sudo apt-get install autoconf automake libtool

截至到現在,最後一次make沒有出錯,但有不錯warning,不管它

sudo make install

 

2. 編譯嵌入式x86版:

進入x86目錄,設定其以QVFB作為顯示輸出

# sudo ./configure -prefix /usr/local/Trolltech/QtEmbedded-4.7.0 -embedded x86 -qt-gfx-qvfb -qt-kbd-qvfb -qt-mouse-qvfb

# sudo make

# sudo make install

編譯安裝PC 版中的 qvfb:

進入pc/tools/qvfb/目錄

#make

#make install

 

3.編譯arm版:

先安裝tslib1.4

下載:http://download.csdn.net/source/2803217

獲得包後,交叉編譯tslib

export PREFIX=/usr/local/tslib #設定目標位置

./autogen.sh    #用於產生configure指令碼

echo "ac_cv_func_malloc_0_nonnull=yes" >arm-linux.cache   

#產生一個cache檔案arm-linux.cache,欺騙configure,

CC=arm-linux-gcc ./configure --host=arm-linux --prefix=$PREFIX --cache-file=arm-linux.cache

make

make install

交叉成功後在目標位置產生/bin、/etc、/include、/lib 4個檔案夾

(編譯的時候注意arm-linux-gcc在當前shell下是不是有效,沒有的話必需事先export進去)

 

qt for arm:

cd arm

在下面建立一個指令碼:

#vim myconfig.sh

 

#!/bin/bash

./configure -prefix /usr/local/Trolltech/QtEmbedded-4.7.0-arm  -opensource -confirm-license -release -shared -embedded arm -xplatform qws/linux-arm-g++ -depths 16,18,24 -fast -optimized-qmake -qt-sql-sqlite -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -little-endian -host-little-endian -no-qt3support -no-libtiff -no-libmng -no-opengl -no-mmx -no-sse -no-sse2 -no-3dnow -no-openssl -no-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 -nomake tools -nomake docs -D__ARM_ARCH_5TEJ__ -qt-mouse-tslib -I/usr/local/gtkdfb/include -L/usr/local/gtkdfb/lib

根據移植需要選擇相應的內容,執行configure

(-qt-mouse-tslib下面是剛剛編譯的tslib1.4的目錄,-D__ARM_ARCH_5TEJ__是為瞭解決下面提到的問題 這裡沒有)

#source myconfig.sh

編譯

#make

#make install

 

可能出錯1:

{standard input}: Assembler messages:

{standard input}:778: Error: register or shift expression expected -- `orr r3,r2,lsl#16'

{standard input}:789: Error: register or shift expression expected -- `orr r2,r3,lsl#16'

{standard input}:7748: Error: register or shift expression expected -- `orr r3,r0,lsl#16'

{standard input}:7761: Error: register or shift expression expected -- `orr r1,r0,lsl#16'

make[1]: *** [.obj/release-shared-emb-arm/qfontengine_ft.o] Error 1

make[1]: Leaving directory `/home/lijian/QT/build/3.4.1gcc/qt-embedded-4.6.2/src/gui'

make: *** [sub-gui-make_default-ordered] Error 2

方案:

To fix this issue patch /src/3rdparty/freetype/include/freetype/config/ftconfig.h Line 330.

 "orr %0, %2, lsl #16/n/t" /* %0 |= %2 << 16 */

to "orr %0, %0, %2, lsl #16/n/t" /* %0 |= %2 << 16 */

PS: 都說是交叉編譯器版本問題,用4.5.1就好了... 沒試過...

可能出錯2:

In file included from ./config.h:26,

from ../JavaScriptCore/pcre/pcre_compile.cpp:44:

../JavaScriptCore/wtf/Platform.h:338:6: #error "Not supported ARM architecture"

make[1]: *** [obj/release/pcre_compile.o] Error 1

make[1]: Leaving directory `/usr/local/qte4.6-arm/src/3rdparty/webkit/WebCore'

make: *** [sub-webkit-make_default-ordered] Error 2

方案:

在參數上加 -D__ARM_ARCH_5TEJ__ 或者 -D__ARM_ARCH_4T

或者修改src/3rdparty/webkit/WebCore/Makefile,在cflags中加入-D__ARM_ARCH_4T__ 修改src/script/Makefile,同上

 

可能出錯3:

warning: libts-0.0.so.0, needed by , not found (try using -rpath or -rpath-link)

undefined reference to `ts_read_raw'

undefined reference to `ts_open'

undefined reference to `ts_fd'

undefined reference to `ts_config'

undefined reference to `ts_close'

undefined reference to `ts_read'

collect2: ld returned 1 exit status

解決辦法:

修改qt-everywhere-opensource-src-4.6.0/mkspecs/qws/linux-arm-g++/qmake.conf 檔案(添加lts參數):

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

 

還有個錯誤是加了-pch 參數引起的,具體錯誤內容忘了。

另外一定要在編譯之前確認arm-linux-gcc等環境在當前shell下是否有效,如果出錯最好拿一份新的源碼再去編譯,之前就是因為沒有換而浪費了很多時間。

安裝完成後,在 /usr/local/Trolltech 目錄中有三個檔案夾:Qt-4.7.0、QtEmbedded-4.7.0、QtEmbedded-4.7.0-arm。

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.