关于树莓交叉编译Qt5
来源:互联网 发布:java过滤器与拦截器 编辑:程序博客网 时间:2024/04/29 06:09
http://qt-project.org/wiki/Qt5OnRaspberryPi
http://qt-project.org/wiki/RaspberryPi_Beginners_guide
---------------------------------------------------------------------------------------------
Simplified guide for getting Qt 5 built and installed on the raspberry pi
Overview
Since the instructions at the RaspberryPi wiki-page can be a bit confusing I’ve created this step-by-step guide to document what works for me. I’m using Ubuntu 12.04, but I don’t see why the instructions wouldn’t work on older / other distros.
Update: I was made aware that another similar guide already existed, and it looks to be more complete than this guide, please seeRaspberryPi_Beginners_guide
Preparing the sysroot and getting the toolchain
Download the Debian Wheezy image from here and flash it on your device: raspberrypi.org download page [raspberrypi.org]
The instructions here are tested with the 2012-08-16-wheezy-raspbian image, but should work with 2012-07-15-wheezy-raspbian as well.
Replace /dev/sde with the location of your SD card as reported by “sudo fdisk -l”. Note that this will overwrite any previous contents on the SD card.
- unzip 2012-08-16-wheezy-raspbian.zip
- sudo dd if=2012-08-16-wheezy-raspbian.img of=/dev/sde bs=1M
- sudo eject /dev/sde
We also mount the wheezy image at /mnt/rasp-pi-rootfs for use as a sysroot during cross compilation of Qt 5. The offset 62914560 is computed by running “sudo fdisk -l” on the .img file, and multiplying the sector size 512 bytes with the start of the Linux partition at sector 122880. It’s the same for 2012-07-15-wheezy-raspbian. Remember to re-mount the image in case you reboot as well, otherwise a lot of confusion might ensue.
- sudo mount -o loop,offset=629145602012-08-16-wheezy-raspbian.img/mnt/rasp-pi-rootfs
Get and extract the Linaro toolchain graciously built and provided by Donald: gcc-4.7-linaro [blueocean.qmh-project.org]
- mkdir ~/rpi
- cd ~/rpi
- wget http://blueocean.qmh-project.org/gcc-4.7-linaro-rpi-gnueabihf.tbz
- tar -xjf gcc-4.7-linaro-rpi-gnueabihf.tbz
The main site seem’s down, there is a mirror on http://swap.tsmt.eu/gcc-4.7-linaro-rpi-gnueabihf.tbz
Get and run the fixQualifiedLibraryPaths script from cross-compile-tools in order to fix broken symlinks in the image.
- cd ~/rpi
- git clone https://git.gitorious.org/cross-compile-tools/cross-compile-tools.git
- cross-compile-tools/fixQualifiedLibraryPaths/mnt/rasp-pi-rootfs ~/rpi/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc
Preparing the Raspberry Pi
The first time you boot the Raspberry Pi you get a configuration menu. Otherwise, manually run raspi-config. Make sure a keyboard is connected viaUSB, and that the raspberry pi is connected to your local area network via a network cable. From this menu you’ll want to run the expand_rootfs option, enable ssh server, set the boot_behaviour to no to prevent X from starting (since we’ll be running Qt directly on top of fullscreenEGL). Also in the memory_split option give VideoCore 128 MB of memory to be able to run the mostGPU hungryQML 2 applications.
Also install rsync which we will later use to copy over the Qt libraries and binaries, and set the root password to enable rsync’ing to the root user.
- # on the raspberry pi, as user pi (password raspberry)
- sudo apt-get update
- sudo apt-get install rsync
- sudo passwd
- # enter root password, I chose raspberry here, same as for the pi user
- sudo reboot
After the raspberry has rebooted it will tell you its IP address above the login prompt. Keep track of this IP address for later.
Building qtbase, qtjsbackend, and qtdeclarative
First we clone the Qt source packages we’re interested in to be able to run qmlscene andQML 2 applications. qtjsbackend needs this not yet integrated patch to work on armv6, so we cherry-pick it:https://codereview.qt-project.org/#change,27256
- cd ~/rpi
- git clone git://gitorious.org/qt/qtbase.git
- git clone git://gitorious.org/qt/qtjsbackend.git
- (cd qtjsbackend && git fetch https://codereview.qt-project.org/p/qt/qtjsbackend refs/changes/56/27256/4 && git cherry-pick FETCH_HEAD)
- git clone git://gitorious.org/qt/qtdeclarative.git
Next we configure and build qtbase. I’ve chosen the prefix /opt/qt5, which is where the qt libraries etc will end up on the device image. You might need to sync qtbase back to change 069469b468c482244c5, since I experienced build issues with the latestHEAD. If you get any build failures it’s a good idea to do “git clean -dxf” in qtbase before trying again, to remove any by-products of the failed build. Note that this will erase any local changes you’ve made to qtbase, so use with caution.
- cd ~/rpi/qtbase
- git checkout 069469b468c482244c5 # if HEAD doesn't build
- ./configure -prefix/opt/qt5-release-device linux-rasp-pi-g++-make libs-device-option CROSS_COMPILE=~/rpi/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf--sysroot/mnt/rasp-pi-rootfs
- # accept the license agreement
- make
- sudo make install
We’re ready to build and install the other modules now, using the qmake built together with qtbase. Since it’s a host tool it’s installed in /opt/qt5/bin outside of the sysroot at /mnt/rasp-pi-rootfs.
Due to a build error I encountered with the latest qtdeclarative I had to use “sudo make”. For reference, theSHA-1 of qtjsbackend I tested was e49f760da4b42c96e9f (+ the cherry-pick above), and qtdeclarative was at bf5f97ae626af46742c315.
- cd ~/rpi/qtjsbackend
- /opt/qt5/bin/qmake
- make
- sudo make install
- cd ~/rpi/qtdeclarative
- /opt/qt5/bin/qmake
- sudo make
- sudo make install
Since qmlscene doesn’t get built automatically, we do it manually. We also build samegame to have aQML 2 example to test.
- cd ~/rpi/qtdeclarative/tools/qmlscene
- /opt/qt5/bin/qmake
- make
- sudo make install
- cd ~/rpi/qtdeclarative/examples/demos/samegame/
- /opt/qt5/bin/qmake
- make
- sudo make install
Getting our /opt/qt5 onto the device
Now it’s just a matter of rsync’ing our /opt/qt5 to the device. Exchange the IP address with your own raspberry pi’s IP address as noted earlier (displayed right after the pi’s boot, above the login prompt). Note the trailing slash on the source directory, without it you’ll end up with /opt/qt5/qt5 on the device.
- rsync -av /mnt/rasp-pi-rootfs/opt/qt5/ root@172.24.91.127:/opt/qt5/
Trying out stuff
ssh into the device as the pi user, and run an example.
- # on the host
- ssh pi@172.24.91.127
- # on the pi
- export LD_LIBRARY_PATH=/opt/qt5/lib/
- # to prevent QML 2 animations from running too slow
- export QML_FIXED_ANIMATION_STEP=no
- /opt/qt5/examples/qtdeclarative/demos/samegame/samegame
samegame should be running now, and you can interact with it if you have a mouse connected to the raspberry pi.
- 关于树莓交叉编译Qt5
- 交叉编译qt5.3.2
- qt5.5.1交叉编译
- 树莓派&qt5交叉编译
- 交叉编译Qt5.8
- 交叉编译Qt5.7
- QT5.8.0交叉编译
- 交叉编译Qt5.9.0
- 关于树莓的交叉编译[备忘]
- Qt5.3.2(OpenGL)交叉编译
- 树莓派 Qt5.7交叉编译
- [置顶] 树莓派&qt5交叉编译
- 【CubieTruck】交叉编译QT5.5.1
- QT5.4.2源码交叉编译
- qt5.6.1-hisiv200-交叉编译
- ubuntu16交叉编译Qt5.9
- imx6ul+QT5.6交叉编译
- VS2012+Qt5.2交叉编译环境搭建
- RTP/RTCP协议介绍
- SharedPreferences清除问题
- Android PowerImageView实现,可以播放动画的强大ImageView
- ie11兼容性问题,jsp在IE11显示不全问题,ie11覆盖内容问题解决方法
- 导航栏的返回文字修改
- 关于树莓交叉编译Qt5
- 研发团队建设的心得体会
- C#操作字符串方法总结<转>
- 黑色星期五,磁盘空间不足,mysql挂掉的解决办法
- Aptana Studio 3 如何汉化,实现简体中文版
- Android开发 调用系统隐藏API
- 北京割双眼皮那家医院好
- 快速搭建hadoop环境
- shell脚本在终端显示每一条指令