Building Qt 5.8 for Raspberry Pi on Debian Jessie
The previous version of Raspbian (aka Debian Jessie) comes with an old (5.3.2) version of Qt (Note: Even Stretch has an old version of Qt 5.7.1, see Raspbian Stretch specific tutorial) that is pretty much outdated and does not support the Raspberry Pi properly. Afaik there are no up-to-date backports so the only way to get the latest version of Qt (at time of writing, using LTS version 5.8.0) up and running on your Pi is to build it yourself.
These instructions will build version of Qt that uses the eglfs interface and therefore runs applications fullscreen, without X11 support. You can optionally add Wayland support by installing the required development packages.
Building Qt on the Raspberry Pi is quite straightforward and in short consist of the following steps:
- Downloading sources
- Preparing the sources
- Installing required dependencies
- Installing optional dependencies
- Configuring the build
- Installing the build
This tutorial is written for the full source of version 5.8.0 but any older or later version should work just as well if you have specific needs.
It is fully possible to build only parts using the submodule specific packages, but this tutorial will not go into that.
- 23.08.2017 - Mention Stretch old version
- 12.03.2017 - New configuration method
Download the Qt 5.8.0 source archive
Un-tar the source archive
Un-tar the source acrhive in a suitable location, with enough space. This will take about 5 minutes on a Raspberry Pi 3 and even more on an older model, so go grab a coffe.
tar xf qt-everywhere-opensource-src-5.8.0.tar.xz
Create a shadow build directory outside of the source tree
mkdir build cd build
Install build dependencies
You will need to install plenty of packages to be able to build Qt. Some packages are optional and depends on your particular needs.
Install required packages
apt-get install build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libsqlite3-dev libssl-dev libpng12-dev libjpeg9-dev libglib2.0-dev
Install optional packages
For bluetooth support:
apt-get install bluez libbluetooth-dev
For audio & gstreamer multimedia support
apt-get install libasound2-dev pulseaudio libpulse-dev libgstreamer0.10-dev libgstreamer-plugins-base1.0-dev
apt-get install libpq-dev libmariadbclient-dev
Printing support using CUPS
apt-get install libcups2-dev
apt-get install libxkbcommon-dev libwayland-dev
Configure the build
For some odd reason Qt insists on being configured for cross-compiling, even when doing a native build. And some options won't work or will make other options fail. Fortunately we can work around it by running the configure script twice, first to get everything detected properly, then to fixup missing features. You can choose to build faster armv7 (For Pi 2 or later only) or slower armv6 (Work on all models), just change linux-rasp-pi-g++ to linux-rasp-pi2-g++ the following configuration commandlines.
Note that we are disabling the qtwebengine as unfortunately compiling them requires more memory than a Pi can provide.
First, run configure with the following options:
../qt-everywhere-opensource-src-5.8.0/configure -v -opengl es2 -eglfs -no-gtk -device linux-rasp-pi-g++ \ -device-option CROSS_COMPILE=/usr/bin/ -opensource -confirm-license -reduce-exports \ -force-pkg-config -nomake examples -no-compile-examples -skip qtwayland -skip qtwebengine -release \ -qt-pcre -ssl -evdev -system-freetype -fontconfig -glib -prefix /opt/Qt5.8
Make sure that the configure script detects Raspberry Pi EGLFS, look for the following output:
QPA backends: DirectFB ............................... no EGLFS .................................. yes EGLFS details: ... EGLFS Rasberry Pi .................... yes
Now run configure again, this time with almost the same options, but with sysroot setting:
../qt-everywhere-opensource-src-5.8.0/configure -v -opengl es2 -eglfs -no-gtk -device linux-rasp-pi-g++ \ -device-option CROSS_COMPILE=/usr/bin/ -opensource -confirm-license -reduce-exports \ -force-pkg-config -nomake examples -no-compile-examples -skip qtwayland -skip qtwebengine -release \ -qt-pcre -ssl -evdev -system-freetype -fontconfig -glib -sysroot / -prefix /opt/Qt5.8 -recheck
Now Qt should be configured properly with all features enabled that we need.
To compile run:
or if you are using any of the quad-core Pis, append the -j4 parameter to build in parallel.
The compilation takes just under 2 hours (108 minutes 15.718 seconds to be exact) on a Raspberry Pi 3 when built with parallel make (make -j4). On a Raspberry Pi 2 it will take a bit more, a build of 5.4.2 took about 3 hours to complete.
real 108m15.718s user 389m28.410s sys 18m38.870s
Install the build
The compilation should finnish without any errors, if it does not, double check that you have all the dependecies installed and run configure correctly.
If all is well, install Qt by running
You now have Qt 5.8 installed in /opt/Qt5.8 ready to be used. To configure your Qt project(s) to build with this version run qmake from the installation directory: