Cross-compiling Qt Embedded 5.5 for Raspberry Pi 2

This tutorial shows how to cross-compile the Embedded build of Qt 5.5 for Raspberry Pi 2. The Embedded build does not use the X11 server and instead displays the GUI directly using the Raspberry Pi framebuffer. We will show how to use a Raspberry Pi cross-compiler to build the Qt5 framework for Raspberry Pi on a Windows machine.

  1. Download a fresh SD card image for your Raspberry Pi. In this tutorial we will use a Debian Jessieimage. Write the image into the SD card using WinFLASHTool or any other similar tool.
  2. Download a cross-toolchain matching the image and install it:
  3. Download and install a MinGW toolchain that will be used to build Windows versions of build tools like Qmake:
  4. Download and install Python 2.7 for Windows and ensure that its directory is added to PATH.
  5. Download the Qt source package (e.g. qt-everywhere-opensource-src-5.5.0.tar.xz) from the Qt Archive.
  6. Before we can build the Qt for Raspberry Pi, we need to resynchronize the sysroot with the toolchain to ensure that the toolchain has all the headers and libraries from your Raspberry. Start the UpdateSysroot.bat file from the <sysgcc>\Raspberry\TOOLS folder:You need to synchronize at least the /opt folder, as it contains OpenGL headers that are not included in the toolchain. If you have installed additional packages on your Raspberry Pi, resynchronize other suggested directories as well.
  7. Launch the msys shell from the MinGW toolchain by running<sysgcc>\MinGW32\msys\1.0\msys.bat:
  8. Go to the directory containing the archive with the Qt source and extract it by running tar xf <archive name>:
  9. Ensure that the directories containing the MinGW gcc compiler and the Raspberry Pi cross-compiler are added to PATH. If not, add them manually:
  10. Open the qt-everywhere-opensource-src-5.5.0\qtbase\mkspecs\linux-arm-gnueabi-g++\qmake.conf  file and replace all occurences of arm-linux-gnueabi- with arm-linux-gnueabihf-:
  11. Now we are ready to build Qt. Due to a bug in the Qmake build script, we will need to build it in 2 steps: first we will build a Qmake for Windows and then we’ll build the actual Qt binaries. First we will modify the win32-g++ platform definition to prevent MinGW from excluding some functions that Qt relies upon. Open the qt-everywhere-opensource-src-5.5.0\qtbase\mkspecs\win32-g++\qmake.conf file and add -U__STRICT_ANSI__ to CXXFLAGS:
  12. Now we can build the Windows tools. Create a directory (e.g. qt-build) and run the configuration script from there:

    1

    2

    3

    mkdir qt-build

    cd qt-build

    ../qt-everywhere-opensource-src-5.5.0/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -opengl es2 -device linux-rasp-pi2-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5

    Note the “-opengl es2″ option that configures Qt to use the Raspberry Pi framebuffer directly instead of the X11 system.

  13. Eventually the build should fail complaining about the errors to process specs for the raspberry device:
  14. This is normal as long as qmake.exe got built. Check this by running “qtbase/bin/qmake -v”:
  15. Now we can build the rest of the Qt framework. First of all open the qtbase\configure file and replace the condition before the “Creating qmake line” with this one:

    1

    if [ ‘!‘ -f "$outpath/bin/qmake.exe" ]; then

  16. Start the configure script again, this time adding the following argument to the end of the previous command line:

    1

    -device-option CROSS_COMPILE=C:/SysGCC/Raspberry/bin/arm-linux-gnueabihf- -qt-xcb

    The -device-option is required when using the device specification, however if you specify it while building Qmake, the Qt build system will try to use the cross-compiler to build the Windows Qmake executable that will obviously fail.

  17. Once the configure script reports that the configuration is complete, run the “make && make install” command to build the entire Qt framework and install it into the cross-compiler directory. The framework is huge, so the build process might take several hours to complete, even on a fast machine.Warning: do not run “make install” before “make” succeeds as it would fail leaving the build directory in a partially built state failing further builds until the entire directory is deleted and re-created.
  18. Open SmarTTY (a portable version can be found in <SysGCC>\Raspberry\TOOLS\PortableSmartty) and connect to your Raspberry Pi. Then run the following commands to create the /usr/local/qt5 folder and make it writable to the current user:

    1

    2

    3

    cd /usr/local

    sudo mkdir qt5

    sudo chown pi qt5

    Then select SCP->Upload directory:

  19. Select the <sysroot>\usr\local\qt5 directory and upload it to /usr/local/qt5:
  20. Wait for the upload to complete. The built Qt framework is relatively large and would take several minutes to upload:
  21. Once the upload is complete, you can test out the framework. Go to the/usr/local/qt5/examples/opengl/qopenglwidget directory and launch ./qopenglwidget:
  22. Look at the screen connected to the HDMI port of the Raspberry Pi. You will see a rotating Qt logo animation:If the screen does not show anything, shut down your Raspberry Pi and re-plug the power connector. As long as the screen is connected when the device is powered on, Raspberry Pi should recognize it.

Now that you have cross-compiled the Qt framework for your Raspberry, follow this tutorial to create and build a basic Qt application using the same cross-compiler.

http://visualgdb.com/tutorials/raspberry/qt/embedded/

时间: 2024-08-06 15:25:45

Cross-compiling Qt Embedded 5.5 for Raspberry Pi 2的相关文章

让QT/Embedded支持国际化

让QT/Embedded支持国际化 环境配置: Qt/Embedded 3.3.8 ,在主机和目标板上存放路径都为:/root/qt-embedded-free-3.3.8 Qt/X11 3.3 (主要用到其中的lupdate,lrelease和lingust工具) 1.修改并重新编译应用程序,使之支持I18N 编辑程序入口文件,在QApplication对象声明之后添加: QTranslator translator; translator.load("pro_zh"); //假设你

Cross compiling coreutils and generate the manpages

When we cross compiling coreutils, there is an problem of generating man pages, because the source script use the binaries generated by make process to produce man pages, but the cross compiled binaries cannot run on build machine. In order to resolv

Raspberry Pi Kernel Compilation 内核编译官方文档

elinux.org/Raspberry_Pi_Kernel_Compilation#Use_the_provided_compiler Software & Distributions: Software - an overview. Distributions - operating systems and development environments for the Raspberry Pi. Kernel Compilation - advice on compiling a ker

Raspberry pi,一个好玩的派:第五季 无线网卡

Raspberry pi的板子由于成本原因是没有加无线模块的,不想被网线束缚的我们,需要自备USB无线模块.在购买板子时,看见官方推荐EDUP无线网卡,价格还算合适,就直接入手了. 采用REALTEK8188芯片,802.11n,传输速度150Mbps,适用范围130平方米. 将其插到任一U口即可,如下图: 由于外壳阻碍了电源插孔,所以只好先裸着了,图中已经加电,HDMI的另一头是电视机. 接下来的任务就是如何让这个无线网卡工作,连接到我已经开启的无线路由器. 一.wpa_gui 在进入Rasp

Raspberry Pi 3 with Openwrt

https://wiki.openwrt.org/toh/raspberry_pi_foundation/raspberry_pi#boot_log_raspberry_pi_3 Table of Contents Supported Versions Hardware Specifications Raspberry Pi SoCs Raspberry Pi Models Using I2C and SPI Power Notes Serial Boot Logs Boot Log (Rasp

安装树莓派 Raspberry PI

安装树莓派 树莓派终于到货了,是这个样子的 上面有一行日期是 Raspberry PI (c) 2011.12 下载镜像,写入SD卡 http://www.raspberrypi.org/downloads/ 选择这个镜像: RASPBIAN Debian 2014-01-07 780M的压缩包,很大的样子 似乎还有个NOOBS的安装方式,完全无感 顺便展示一下SD卡,通过查阅可用SD卡列表,似乎是支持个别的64G Class10的卡的,就像这个,编号是 Transcend SDXC 64G C

[转] Raspberry Pi 樹莓派使用場合及時機

在買了 Raspberry Pi 後,到底能拿來做什麼事情呢?有幾個想法一起分享 這裡有初學者教學的影片,非常值得一看. http://www.youtube.com/user/RaspberryPiBeginners 1. 插上擴充卡,DIY 或教學. 當然最主要用法,插上 GPIO 卡,接上麵包板,拉一些電路,控制 LED 來顯示些什麼,或是生產啤酒 (http://forum.talkonly.net/viewthread.php?tid=15049) 等等,似乎是主要的用法. 2. 放在

RASPBERRY PI 外设学习资源

参考: http://www.siongboon.com/projects/2013-07-08_raspberry_pi/index.html Raspberry Pi         Get started with Raspberry Pi (RPi), a step by step approach to get your Raspberry Pi with low level electronics hardware control. Make simple, step by step

VNC connect to raspberry pi under ubuntu desktop environment

1 使用Remmina Remote Desktop ubuntu 14.04自带一款远程桌面叫作 Remmina Remote Desktop 利用它即可方便打开已经开启VNC server的raspberry pi 如图,已经新建好了一个raspberry的链接. 新建服务链接 填写链接name 选择链接所使用protocol,注意要选VNC 填写server的地址 填写登录user name以及password 如图: 2 使用SSL/SSH VNC Viewer 下载vnc viewer