這篇文章主要介紹了樹莓派如何實現Qt5交叉編譯移植,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
![](/upload/ad_content/xuanchuantu-15.jpg)
成都創新互聯公司服務項目包括定西網站建設、定西網站制作、定西網頁制作以及定西網絡營銷策劃等。多年來,我們專注于互聯網行業,利用自身積累的技術優勢、行業經驗、深度合作伙伴關系等,向廣大中小型企業、政府機構等提供互聯網行業的解決方案,定西網站推廣取得了明顯的社會效益與經濟效益。目前,我們服務的客戶以成都為中心已經輻射到定西省份的部分城市,未來相信會繼續擴大服務區域并繼續獲得客戶的支持與信任!
Raspberry Pi (BCM2835): Device Information
Architecture | ARMv6 | CPU | ARM11 |
RAM | 256MB OR 512MB since October 2012 (shared with GPU) |
GPU | VideoCore IV |
OpenGL | OpenGL ES 2.0 |
Multimedia | OpenMax IL 1.1.2 |
Qt 5.0 (eglfs/QPA) | Supported, with OpenGL ES 2.0 |
Qt 5 port functional state (against Raspbian Wheezy (primary reference platform))
Feature | State | Additional info | Hardware accelerated cursor | Done | upstream |
Wayland support | Done | upstream |
Hardware decoding of images | To Do |
|
Scenegraph tailoring | To Do |
|
HardFP support | Done | Requires v8 patch |
Qt Multimedia | Done | Requires gst-omx |
Webkit integration | To Do | webgl, tex mapper |
開始
首先我們先創建一個目錄來存放Qt5的源代碼以及交叉編譯所需要的所有文件,我選擇在當前用戶家目錄下創建一個叫做“opt”的目錄。
1 | diveinedu@debian :~$ mkdir ~ /opt |
2 | diveinedu@debian :~$ cd ~ /opt |
然后,下載以下文件:
下載Raspbian Wheezy 鏡像 (這里下載 [raspberrypi.org]):
1 | diveinedu@debian :~ /opt $ wget http: //downloads .raspberrypi.org /images/raspbian/2013-02-09-wheezy-raspbian/2013-02-09-wheezy-raspbian .zip |
2 | diveinedu@debian :~ /opt $unzip 2013-02-09-wheezy-raspbian.zip |
下載解壓完后掛載鏡像:
1 | diveinedu@debian :~ /opt $ sudo mkdir /mnt/rasp-pi-rootfs |
2 | diveinedu@debian:~ /opt $ sudo mount -o loop,offset=62914560 2013-03-09-wheezy-raspbian.img /mnt/rasp-pi-rootfs |
我們這不介紹交叉工具鏈的編譯,直接下載針對樹莓派優化定制的交叉編譯工具鏈(或者用github上樹莓派的工具鏈https://github.com/raspberrypi/tools):
1 | diveinedu@debian:~ /opt $ wget http: //blueocean .qmh-project.org /gcc-4 .7-linaro-rpi-gnueabihf.tbz |
2 | diveinedu@debian:~ /opt $ tar -xf gcc-4.7-linaro-rpi-gnueabihf.tbz |
因為上面的交叉編譯工具是32位Linux的,如果你所使用的是64位Linux的話,還需要安裝32位的運行庫軟件包:
1 | diveinedu@debian:~ /opt $ sudo apt-get install ia32-libs |
如果用的是Debian Wheezy的64位系統,上面的行不通,因為Debian Wheezy 64位開啟了multiarch-support ,需要執行:
1 | diveinedu@debian:~/opt$ sudo apt-get install multiarch-support |
2 | diveinedu@debian:~/opt$ sudo dpkg --add-architecture i386 |
3 | diveinedu@debian:~/opt$ sudo apt-get update |
4 | diveinedu@debian:~/opt$ sudo apt-get install ia32-libs |
從遠程倉庫克隆一份cross-compile-tools到本地:
1 | diveinedu@debian:~ /opt $ git clone git: //gitorious .org /cross-compile-tools/cross-compile-tools .git |
從遠程倉庫克隆一份Qt5的源碼庫到本地:
1 | diveinedu@debian:~ /opt $ git clone git: //gitorious .org /qt/qt5 .git |
2 | diveinedu@debian:~ /opt $ cd qt5 |
3 | diveinedu@debian:~ /opt/qt5 $ . /init-repository |
最后,把qtjsbackend子項目打補丁讓其支持armv6指令集的樹莓派:
1 | diveinedu@debian:~ /opt/qt5 $ cd ~ /opt/qt5/qtjsbackend |
2 | diveinedu@debian:~ /opt/qt5 $ git fetch https: //codereview .qt-project.org /p/qt/qtjsbackend refs /changes/56/27256/4 && git cherry-pick FETCH_HEAD |
如果有沖突的話就解決沖突的代碼。
編譯qtbase
現在我們已經準備好了為樹莓派交叉編譯Qt5所需要的全部資源,在正式編譯之前只需要執行一個小腳本來修正一下符號鏈接和庫文件路徑設置:
1 | diveinedu@debian:~ /opt/qt5 $ cd ~ /opt/cross-compile-tools |
2 | diveinedu@debian:~ /opt/qt5 $ sudo . /fixQualifiedLibraryPaths /mnt/rasp-pi-rootfs/ ~ /opt/gcc-4 .7-linaro-rpi-gnueabihf /bin/arm-linux-gnueabihf-gcc |
進入qt5/qtbase目錄執行以下腳本進行配置和編譯工作:
1 | diveinedu@debian:~ /opt/qt5 $ cd ~ /opt/qt5/qtbase |
2 | diveinedu@debian:~ /opt/qt5/qtbase $ . /configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~ /opt/gcc-4 .7-linaro-rpi-gnueabihf /bin/arm-linux-gnueabihf- -sysroot /mnt/rasp-pi-rootfs -opensource -confirm-license -optimized-qmake -reduce-relocations -reduce-exports -release - make libs -prefix /usr/local/qt5pi -no-pch |
3 | diveinedu@debian:~ /opt/qt5/qtbase $ make -j 4 |
4 | diveinedu@debian:~ /opt/qt5/qtbase $ sudo make install |
編譯其他模塊
執行到這步的時候,你已經有了針對樹莓派交叉編譯的qmake工具了,你可以一一的去交叉編譯Qt5的其他模塊了,為里避免模塊編譯過程中可能 出現的依賴錯誤,建議按照這個模塊順序去編譯: qtimageformats, qtsvg, qtjsbackend, qtscript, qtxmlpatterns, qtdeclarative, qtsensors, qt3d, qtgraphicaleffects,qtjsondb,qtlocation, qtdocgallery.
模塊編譯相關的類似命令:
1 | diveinedu@debian:~ /opt/qt5 $ cd qtimageformats |
2 | diveinedu@debian:~ /opt/qt5/qtimageformats $ /usr/local/qt5pi/bin/qmake . |
3 | diveinedu@debian:~ /opt/qt5/qtimageformats $ make -j4 |
4 | diveinedu@debian:~ /opt/qt5/qtimageformats $ sudo make install |
把你所需要或者所想編譯的模塊都按順序執行編譯安裝命令后,所有需要的東西都安裝在了鏡像文件(raspbain wheezy image)里面了。我們接下來就是把他燒到SD卡上去。 SD卡燒寫命令:
1 | diveinedu@debian:~ /opt/qt5 $ cd ~ /opt/ |
2 | diveinedu@debian:~ /opt $ sync ; sudo umount /mnt/rasp-pi-rootfs |
3 | diveinedu@debian:~ /opt $ sudo dd bs=1M if =2013-02-09-wheezy-raspbian.img of= /dev/sdc ; sync |
提示:/dev/sdc是我使用的SD的設備, 請根據自己的實際情況修改。
感謝你能夠認真閱讀完這篇文章,希望小編分享的“樹莓派如何實現Qt5交叉編譯移植”這篇文章對大家有幫助,同時也希望大家多多支持創新互聯,關注創新互聯行業資訊頻道,更多相關知識等著你來學習!
當前名稱:樹莓派如何實現Qt5交叉編譯移植
瀏覽路徑:http://m.newbst.com/article44/jeesee.html
成都網站建設公司_創新互聯,為您提供企業網站制作、網站制作、全網營銷推廣、動態網站、企業建站、網站收錄
廣告
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源:
創新互聯