My Firmware

My Firmware

Embedded development

© 2020

Compiling Qt natively on Raspberry Pi

I want to be able to build user interfaces for programs running on Raspberry Pis with touch screen displays attached and since I’ve been doing some Qt development at work I wanted to use it. However the repositories-provided Qt doesn’t support EGLFS which is used for rendering using the original drivers. And when I switched to VC4 there was no output on the display. So I needed to compile my own Qt binaries.

As a source tutorial I used this one with small modifications: original tutorial

My steps were:

  1. increase swap size
  2. launch these commands
    tar xf qt-everywhere-src-5.12.5.tar.xz
    git clone
    cd qt-raspberrypi-configuration && make install DESTDIR=../qt-everywhere-src-5.12.5
    cd ..
    mkdir -p build
    cd build
    sudo apt-get install build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libsqlite3-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev
    sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad libgstreamer-plugins-bad1.0-dev gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-alsa
    sudo apt-get install libsdl2-dev # gamepad support
    PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig ../qt-everywhere-src-5.12.5/configure -platform linux-rpi3-g++ -v -opengl es2 -eglfs -no-gtk -opensource -confirm-license -release -reduce-exports -force-pkg-config -nomake examples -no-compile-examples -skip qtwayland -skip qtwebengine -skip qt3d -skip qtpurchasing -skip qtcharts -skip qtvirtualkeyboard -no-feature-geoservices_mapboxgl -qt-pcre -no-pch -ssl -evdev -system-freetype -fontconfig -glib -prefix /opt/Qt5.12 -qpa eglfs -no-xcb -skip qtscript
    make -j4
    sudo make install

    The build took at least half a day on a Raspberry Pi 3 B+, which is a lot so I recommend running it overnight.

To use such compiled Qt in a cmake application, you need to add the following lines to CMakeLists.txt.

set(Qt5_DIR /opt/Qt5.12/lib/cmake/Qt5/)
set(QML_IMPORT_PATH /opt/Qt5.12/qml)

Your application can then be launched with EGLFS by adding the --platform eglfs argument when running it.