開始
首先咱們先建立一個目錄來存放Qt5的源代碼以及交叉編譯所須要的全部文件,我選擇在當前用戶家目錄下建立一個叫作「opt」的目錄。linux
而後,下載如下文件:git
下載Raspbian Wheezy 鏡像 (這裏下載 [raspberrypi.org]):github
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 |
下載解壓完後掛載鏡像:web
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):json
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位的運行庫軟件包:app
1 |
diveinedu@debian:~ /opt $ sudo apt-get install ia32-libs |
若是用的是Debian Wheezy的64位系統,上面的行不通,由於Debian Wheezy 64位開啓了multiarch-support ,須要執行:ide
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到本地:svg
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指令集的樹莓派:oop
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 |
若是有衝突的話就解決衝突的代碼。
編譯其餘模塊
執行到這步的時候,你已經有了針對樹莓派交叉編譯的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運行庫的編譯移植過程就Done了。
後續會有例程Demo以及Qt5的QPA機制在樹莓派上的eglfs平臺插件的特色介紹和傳統QtWidget程序在EGLFS環境下遇到的問題和解決分析。
C/C++開發,嵌入式Linux,嵌入式開發, Qt開發, Qt5移植 等, 盡在長沙戴維營教育 ,歡迎前來學習。