Linux 下 Qt 4.6.0 嵌入式開發環境的搭建、移植 轉自紫俠大哥的博文

來源:互聯網
上載者:User

Qt:qt-everywhere-opensource-src-4.6.0.tar.gz
嵌入式平台:2440
arm-linux-gcc:4.1.2,下載(我用4.3.2和4.4.1版本時,移植時都有段錯誤。我把它放在:/usr/local/arm/4.1.2/ 。)

將 qt-everywhere-opensource-src-4.6.0.tar.gz 壓縮包解壓為3份,分別編譯 PC ,嵌入式 x86 和 arm 三個版本。

1. 編譯 PC 版:
$ ./configure
$ make
# make install

2. 編譯嵌入式x86版:
$ ./configure -embedded x86 -qt-gfx-qvfb -qt-kbd-qvfb -qt-mouse-qvfb
$ make
# make install

編譯安裝PC版中的 qvfb:
$ cd  ***/qt-everywhere-opensource-src-4.6.0/tools/qvfb
$ make
# cp ***/qt-everywhere-opensource-src-4.6.0/bin/qvfb  /usr/local/Trolltech/QtEmbedded-4.6.0/bin

3. 編譯嵌入式arm版(需要 arm-linux-gcc 的支援):

編譯tslib對觸控螢幕支援:
下載,tslib1.4.tar.gz,解壓後:
$ ./configure --prefix=/usr/local/tslib/ --host=arm-linux ac_cv_func_malloc_0_nonnull=yes
$ make 
# make install

設定環境變數,以便編譯時間找到相關的庫:
$ export CPLUS_INCLUDE_PATH=/usr/local/arm/4.1.2/arm-angstrom-linux-gnueabi/include/c++:/usr/local/arm/4.1.2/arm-angstrom-linux-gnueabi/include/c++/arm-angstrom-linux-gnueabi

配置:
$ ./configure /
-opensource /
-confirm-license /
-release -shared /
-embedded arm /
-xplatform qws/linux-arm-g++ /
-depths 16,18,24 /
-fast /
-optimized-qmake /
-pch /
-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 /
-qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib

配置結果:
Debug ............... no
Qt 3 compatibility .. no
QtDBus module ....... no
QtConcurrent code.... yes
QtScript module ..... yes
QtScriptTools module  yes
QtXmlPatterns module  no
Phonon module ....... no
Multimedia module ... yes
SVG module .......... yes
WebKit module ....... no
Declarative module .. no
STL support ......... no
PCH support ......... yes
MMX/3DNOW/SSE/SSE2..  no/no/no/no
iWMMXt support ...... no
IPv6 support ........ yes
IPv6 ifname support . yes
getaddrinfo support . yes
getifaddrs support .. yes
Accessibility ....... yes
NIS support ......... no
CUPS support ........ no
Iconv support ....... no
Glib support ........ no
GStreamer support ... auto
Large File support .. yes
GIF support ......... plugin
TIFF support ........ no
JPEG support ........ plugin (qt)
PNG support ......... yes (qt)
MNG support ......... no
zlib support ........ yes
Session management .. no
Embedded support .... arm
Freetype2 support ... yes
Graphics (qt) ....... linuxfb multiscreen
Graphics (plugin) ... 
Decorations (qt) .... styled windows default
Decorations (plugin)  
Keyboard driver (qt). tty
Keyboard driver (plugin) 
Mouse driver (qt) ... pc linuxtp tslib
Mouse driver (plugin) 
OpenGL support ...... no
OpenVG support ...... no
SQLite support ...... qt (qt)
OpenSSL support ..... no 
alsa support ........ yes

編譯:$ make 

如果出錯:
/usr/local/arm/4.1.2/bin/../lib/gcc/arm-angstrom-linux-gnueabi/4.1.2/../../../../arm-angstrom-linux-gnueabi/bin/ld: warning: libts-0.0.so.0, needed by /home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so, not found (try using -rpath or -rpath-link)
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_read_raw'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_open'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_fd'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_config'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_close'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_read'
collect2: ld returned 1 exit status
make[2]: *** [deform] Error 1
make[2]: Leaving directory `/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/demos/deform'
make[1]: *** [sub-deform-make_default] Error 2
make[1]: Leaving directory `/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/demos'
make: *** [sub-demos-make_default-ordered] Error 2

解決辦法:
修改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

參考:http://74.125.153.132/search?q=cache:3WzcJeRRj4sJ:nckuhuahua.pixnet.net/blog/post/30066956+libQtGui.so:+undefined+reference+to+%60ts_read%27&cd=3&hl=en&ct=clnk&client=iceweasel-a

添加環境變數:# export PATH=/usr/local/arm/4.1.2/bin:$PATH

安裝:# make install-strip

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

測試嵌入式 x86 :
$ source ~/.setenv-qt-x86.sh
$ qvfb -width 800 -height 600 &
$ /usr/local/Trolltech/QtEmbedded-4.6.0/demos/books/books -qws

4、編寫環境變數設定檔案(方便不同環境切換):

PC 機的~/.bashrc 中添加:
export PATH=$PATH:/usr/local/arm/4.1.2/bin

~/.setenv-qt-x11.sh(對應於PC版Qt):
PATH=/usr/local/Trolltech/Qt-4.6.0/bin:$PATH
LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.6.0/lib:$LD_LIBRARY_PATH
CPLUS_INCLUDE_PATH=

~/.setenv-qt-x86.sh:
QTEDIR=/usr/local/Trolltech/QtEmbedded-4.6.0
PATH=/usr/local/Trolltech/QtEmbedded-4.6.0/bin:$PATH
LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.6.0/lib:$LD_LIBRARY_PATH

~/.setenv-qt-arm.sh:
QTEDIR=/usr/local/Trolltech/QtEmbedded-4.6.0-arm
PATH=/usr/local/Trolltech/QtEmbedded-4.6.0-arm/bin:$PATH
LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.6.0-arm/lib:$LD_LIBRARY_PATH
CPLUS_INCLUDE_PATH=/usr/local/arm/4.1.2/arm-angstrom-linux-gnueabi/include/c++:/usr/local/arm/4.1.2/arm-angstrom-linux-gnueabi/include/c++/arm-angstrom-linux-gnueabi:$CPLUS_INCLUDE_PATH

5、移植
將 PC 機上  /usr/local/Trolltech/QtEmbedded-4.6.0-arm/lib 中的庫複製到2440的 /usr/local/Trolltech/QtEmbedded-4.6.0-arm/lib(對應目錄複寫)。

將 PC 機上  /usr/local/tslib 中的庫複製到2440的 /usr/local 。

如果運行時還缺少其他的庫,複製方法相同。

為支援觸控螢幕,開機自動化佈建環境變數,在2440的 /etc/profile中追加:
export LD_LIBRARY_PATH=/usr/local/lib:$QTDIR/lib:$LD_LIBRARY_PATH                                                  
export TSLIB_ROOT=/usr/local/lib     
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb0  
export TSLIB_PLUGINDIR=/usr/local/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_CONFFILE=/usr/local/etc/ts.conf
export POINTERCAL_FILE=/etc/pointercal
export TSLIB_CALIBFILE=/etc/pointercal
export QWS_MOUSE_PROTO=Tslib:/dev/input/event0

註:可用$ cat /dev/input/event0 測試觸控螢幕

取消/usr/local/etc/ts.conf中的第一個注釋:
# module_raw input (去掉#,並且該行頂格)

運行 /usr/local/bin/ts_calibrate 校正觸控螢幕。

6、程式編譯:
PC版:
$ make distclean 
$ source ~/.setenv-qt-x11.sh
$ qmake
$ make

arm 版:
$ make distclean 
$ source ~/.setenv-qt-arm.sh
$ qmake
$ make

參考:
http://blog.ednchina.com/gurongjiang/352778/Message.aspx

相關文章

聯繫我們

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