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/

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

  1. Compiling a kernel module for the raspberry pi 2 via Ubuntu host

    Compiling a kernel module for the raspberry pi 2 via Ubuntu host Normally compiling a kernel module ...

  2. Cross compiling coreutils and generate the manpages

    When we cross compiling coreutils, there is an problem of generating man pages, because the source s ...

  3. 让QT/Embedded支持国际化

    让QT/Embedded支持国际化 环境配置: Qt/Embedded ,在主机和目标板上存放路径都为:/root/qt-embedded-free- Qt/X11 3.3 (主要用到其中的lupda ...

  4. QT Embedded二三事之QObject的元对象

    一.元对象  元对象被称做是meta object.在运行时刻(runtime),能够提供对象的运行时信息.        在C++语言发展的早期,C++语言本身没有定义对象的运行时信息,如输出类的名 ...

  5. Raspberry Pi 3 --- Kernel Building and Run in A New Version Kernal

    ABSTRACT There are two main methods for building the kernel. You can build locally on a Raspberry Pi ...

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

    elinux.org/Raspberry_Pi_Kernel_Compilation#Use_the_provided_compiler Software & Distributions: S ...

  7. RASPBERRY PI 外设学习资源

    参考: http://www.siongboon.com/projects/2013-07-08_raspberry_pi/index.html Raspberry Pi         Get st ...

  8. [树莓派(raspberry pi)] 02、PI3安装openCV开发环境做图像识别(详细版)

    前言 上一篇我们讲了在linux环境下给树莓派安装系统及入门各种资料 ,今天我们更进一步,尝试在PI3上安装openCV开发环境. 博主在做的过程中主要参考一个国外小哥的文章(见最后链接1),不过其教 ...

  9. Device trees, Overlays and Parameters of Raspberry Pi

    Raspberry Pi's latest kernels and firmware, including Raspbian and NOOBS releases, now by default us ...

随机推荐

  1. 【转】Android UI系列-----时间、日期、Toasts和进度条Dialog

    原文网址:http://www.cnblogs.com/xiaoluo501395377/p/3421727.html 您可以通过点击 右下角 的按钮 来对文章内容作出评价, 也可以通过左下方的 关注 ...

  2. Listen第二个参数的意义

    今天主要回顾下listen的第二个参数的意义. 话说现在现在都是用框架写业务代码.真的很少在去关注最基本的socket函数的意义了.该忘得都忘得差不多了.~~~  要慢慢捡起来.  主要是在看redi ...

  3. 手势触摸定位(UIPanGestureRecognizer)

    /** 1.相对于父坐标系而言,表示当前触摸点所在的位置 */ CGPoint locationPoint = [panGestureRecognizer locationInView:panGest ...

  4. 详细介绍android rom移植知识普及

    详细介绍android rom移植知识普及 最近接到很多兄弟们的求助,也回答过无数个和下面这个问题类似的问题: 如何编译android 原生代码得到一个rom,然后跑到某某手机上. 鉴于很多兄弟对这块 ...

  5. oracle触发器实例

    8.1 触发器类型 8.1.1 DML触发器 8.1.2 替代触发器 8.1.3 系统触发器 8.2 创建触发器 8.2.1 触发器触发次序 8.2.2 创建DML触发器 8.2.3 创建替代(INS ...

  6. 字符串数组越界bug(2)

    概述 数组下标从0開始,尽管从初学都已经知道,<陷阱与缺陷>重复强调,而在指尖运动中,就有那么几次不小心,让"精子"掉进这个"洞里"!其次,C语言字 ...

  7. 自定义控件(视图)2期笔记01:自定义控件之自定义View的步骤

    1. 根据Android Developers官网的介绍,自定义控件你需要以下的步骤: (1)创建View (2)处理View的布局 (3)绘制View (4)与用户进行交互 (5)优化已定义的Vie ...

  8. samba服务日志文件-密码文件及启停

    1.Samba服务日志文件日志文件对于samba非常重要,它存储着客户端访问samba服务器的信息,以及samba服务的错误提示信息等,可以通过分析日志,帮助解决客户端访问和服务器维护等问题.在/et ...

  9. Selenium2学习之-环境搭建

    1.下载安装Eclipse 2.下载并配置jdk环境变量 2.1 介绍一下环境变量设置 2.1.1 点击环境变量 2.1.2 新增系统变量JAVA_HOME 变量名:JAVA_HOME 变量值:C:\ ...

  10. java listener实现定时任务

    使用java ServletContextListener 实现各种简单定时任务. 1. 创建ServletContextListener,在3.0版本的web.xml中不再需要添加listener的 ...