Cross-compiling Qt 5.5 for Beaglebone-Debian

This tutorial shows how to cross-compile the Qt 5.5 framework for Beaglebone-Debian. We will build the X11-based version of Qt for the Beaglebone Black board.

Warning: Modern Beaglebone Debian distributions include a pre-built version of Qt that can be used by VisualGDB out-of-the-box. Follow this tutorial to create a cross-compiled Qt5 app based on the pre-built Qt package. The rest of this tutorial demonstrates building of the Qt framework from scratch that can be useful if you need specific Qt configuration that is different from the default package.

  1. Download an SD card image to your Beaglebone and get a matching cross-toolchain:toolchain
  2. Download and install a MinGW toolchain that will be used to build the Windows-side build tools like Qmake:02-mingw
  3. Download and install Python 2.7 for Windows and ensure that its directory is added to PATH.
  4. Download the Qt source package (e.g. qt-everywhere-opensource-src-5.5.0.tar.xz) from the Qt Archive.
  5. If you installed additional packages to your Beaglebone, you will need to resynchronize the sysroot with the toolchain to ensure that the toolchain has all the headers and libraries from your Beaglebone. Start the UpdateSysroot.bat file from the <sysgcc>\Beaglebone\TOOLS folder and synchronize the suggested directories.
  6. Launch the msys shell from the MinGW toolchain by running<sysgcc>\MinGW32\msys\1.0\msys.bat:04-shell
  7. Go to the directory containing the archive with the Qt source and extract it by running tar xf <archive name>:05-unpack
  8. Ensure that the directories containing the MinGW gcc compiler and the Beaglebone cross-compiler are added to PATH. If not, add them manually:pathsEnsure the the default ‘make’ executable is the one from the MinGW build folder. If not, add the /bin folder to the beginning of PATH.
  9. Now we will edit the device configuration file to fix the build and enable X11 as the default GUI platform for Qt. Comment out the “-mfloat-abi” setting and change QT_QPA_DEFAULT_PLATFORM to xcb:fp
  10. 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:06a-strictansi
  11. Now we can build the Windows tools. Create a directory (e.g. qt-build) and run the configuration script from there:
    mkdir qt-build
    cd qt-build
    ../qt-everywhere-opensource-src-5.5.0/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -device linux-beagleboard-g++ -sysroot C:/SysGCC/Beaglebone/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5


  12. Eventually the build should fail complaining about the errors to process specs for the Beaglebone device. This is normal as long as qmake.exe got built. Check this by running “qtbase/bin/qmake -v”:qmake
  13. 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:
    if [ '!' -f "$outpath/bin/qmake.exe" ]; then


  14. Start the configure script again, this time adding the following argument to the end of the previous command line:
    -device-option CROSS_COMPILE=C:/SysGCC/Beaglebone/bin/arm-linux-gnueabihf- -qt-xcb

    configuredThe -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.

  15. 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.instdoneWarning: 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.
  16. Open SmarTTY (a portable version can be found in <SysGCC>\Beaglebone\TOOLS\PortableSmartty) and connect to your Beaglebone. Then run the following commands to create the /usr/local/qt5 folder and make it writable to the current user:
    cd /usr/local
    sudo mkdir qt5
    sudo chown pi qt5


  17. Then select SCP->Upload directory and upload the <sysroot>\usr\local\qt5 directory to /usr/local/qt5:upload
  18. Go to the /usr/local/qt5/examples/widgets/dialogs/classwizard directory and run ./classwizard:classw
  19. If Qt complains about missing QT_XKB_CONFIG_ROOT variable and the keyboard does not work, you can define it by running the following command:
    export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb
  20. Then the example will start normally (the QXcbConnection error can be ignored):xkb
  21. You will see the Qt class wizard window forwarded from the remote machine:classwinFollow this tutorial to learn how to create Qt projects for Beaglebone-Debian with Visual Studio.