Building Qt 5.8 for Raspberry Pi on Debian Stretch

25/09/2017 - 17:39
Average: 4 (1 vote)

Raspbian based on Debian Stretch comes with an old (5.7.1) version of Qt that is already outdated and missing some features and modules. Afaik there are no up-to-date backports so the only way to get an up to date version version of Qt with all features enabled running on your Pi is to build it yourself. We will use the LTS release branch, version 5.8.0 for now.

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:

  1. Downloading sources
  2. Preparing the sources
  3. Installing required dependencies
  4. Installing optional dependencies
  5. Configuring the build
  6. Compiling
  7. 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.


  • 04.09.2017 - Initial version published

Download the Qt 5.8.0 source archive

Download the single source tar file from, version 5.8.0. The package is quite large, 354M, so depending on your bandwidth it might take some time to download.


Un-tar the source archive

Un-tar the source acrhive in a suitable location, with enough space. This will take 7-8 minutes on a Raspberry Pi 3 and even more on an older model, so go grab of coffe.

tar xf qt-everywhere-opensource-src-5.8.0.tar.xz

real    7m44.417s
user    1m38.700s
sys    0m25.820s

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

Install required development packages

apt-get install build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libsqlite3-dev libssl1.0-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev
Note about OpenSSL 1.0.2 and 1.1.0

Stretch uses OpenSSL 1.1.0 that breaks source compatibility and unfortunately Qt 5.8 does not support that version (there are patches available). But, fortunately Stretch does still provide version OpenSSL 1.0.2! That is why we install libssl1.0-dev above.

Install optional development packages

Qt consist of many modules, depending on your needs you might like to install additinal development packages to be able to enable support for these features in Qt. Check the list below for optional features and the required development packages for them. Make sure that the feature you need is enabled at the end of the configure run.

For bluetooth support:

apt-get install bluez libbluetooth-dev

For audio & gstreamer multimedia support

apt-get install libasound2-dev pulseaudio libpulse-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-alsa gstreamer-tools

Support for various databases (PostgreSQL, MariaDB/MySQL)

apt-get install libpq-dev libmariadbclient-dev

Printing support using CUPS

apt-get install libcups2-dev

Wayland support

apt-get install libwayland-dev

Configure the build

For some odd reason Qt insists on being configured for cross-compiling, even when doing a native build. Fortunately we can work around it by specifying a couple of extra parameters to get everything detected properly.
You can choose to build a generic build that will work on all of the various Pi versions or specifc one that is optimized for your specific type of board. Choose one of:

  • linux-rasp-pi-g++ for a ARMv6 compatible version, runs on all Raspberry Pi models
  • linux-rasp-pi2-g++ for a ARMv7 optimized version, runs on Raspberry Pi 2 & 3
  • linux-rpi3-g++ for a ARMv8 optimized version, runs on Raspberry Pi 3

Change the configure option linux-rasp-pi-g++ to any of the above to suit your needs.

Note that we are disabling the qtwebengine as unfortunately compiling it requires more memory than a Pi can provide.

Run configure with the following options:

PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig PKG_CONFIG_SYSROOT_DIR=/ \
../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 Qt should be configured properly with all features enabled that we need. If you need some of the optional features, make sure to check the configure result that they where properly detected.

Compile Qt

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

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

make install

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:


Happy coding!


raspberry pi