Qt 6 on the Raspberry Pi on eglfs

Featured Video Play Icon

It has been some time since Qt 6 was released. Now that Qt 6.2 is almost out, I guess it is time to have a look at how Qt 6 runs on eglfs on a Raspberry Pi.

Building Qt 6

Qt 6 moved from qmake to cmake. This makes a difference when trying to build it and cross-build it. Instructions on how to build are already available online from many sources, so I won’t repeat the theory here. I just want to note a few key points.

Configuration

I configured this build in the simplest form. To start, I want to use eglfs on OpenGL ES.

Toolchain

Building Qt requires a toolchain for building on the host and a toolchain to build for the target (the Raspberry Pi in this case). The toolchain from the host is typically provided by your distro (I used Manjaro in this case), while the toolchain to cross-build for the Raspberry Pi is officially provided here. In the past years I had a lot of weird problems building with those toolchains, so I started to create my own. Never had any problem anymore. Here you can find the toolchains:

  • Raspberry OS Stretch: here;
  • Raspberry OS Buster: here.

Please note that those toolchains are not always able to target every arch.

The one for Buster is the one I used in my build, and the target arch is armv8-a.

Dependencies

Dependencies are already listed elsewhere. I would only like to note one thing here: I had problems linking because of a missing symbol: qt_resourceFeatureZstd. According to the sources, it seems that resources are compiled by the rcc tool. My guess is that the host tools use zstd by default to compress when available, but this is a problem when zstd is available on the host and not available on the target. Therefore, I suspect you have to decide if you want zstd support or not before building Qt 6 for the host, and be coherent with the build for the target. I decided to add zstd.

Build Errors

I had a few build errors building Qt 6.2 beta3. Nothing particularly relevant, but I had to apply a few changes. I did not keep track of those changes, they were all trivial.

Build Qt Test App

Once the Qt builds are ready, it is time to run. For the moment, I only want to do a quick test of QML. In my build, I forgot to set eglfs as the default platform, but it can be set it in the environment. I wrote a simple app to test Qt Quick here. The animations are very simple, but I wrote it like this to see how well many items are handled and how well the uniform movement on the y axis is rendered.

NOTE: Unlike Qt5, Qt6 includes host tools and tools built for the target. This means you can build the test app on the target directly or cross-build it from your host. For the package below anyway, you’d need to have a system compatible with those binaries.

First App

This video shows a comparison of this Qt 6 build against Qt 5. It also shows the same benchmark app on Intel UHD and nVidia.

Download

If you want to test the build of Qt 6 on your rpi, you can download it from here:

Download Qt 6.2.0-rc1 for Raspberry OS Buster armv8-a

The package does not include the toolchain, that you can download from the other links, but includes the host build. I don’t think it will be of help, as it is built for my Manjaro context, but I placed it there anyway.

The positions of the directories are relevant:

  • /opt/rpi/rpi-8.6.3: toolchain;
  • /opt/Qt-x64-6.2.0-beta3: host build;
  • /usr/local/Qt-rasp-6.2.0-beta3: position in the target;
  • /opt/rpi/sysroot: sysroot for cross-building.

Runtime Context

The is the 3D environment as seen by Qt 6:

qt.rhi.general: Created OpenGL context QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 0, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::DefaultSwapBehavior, swapInterval 1, colorSpace QColorSpace(), profile  QSurfaceFormat::NoProfile)
qt.rhi.general: OpenGL VENDOR: Broadcom RENDERER: VC4 V3D 2.1 VERSION: OpenGL ES 2.0 Mesa 19.3.2
qt.scenegraph.general: MSAA sample count for the swapchain is 1. Alpha channel requested = no.
qt.scenegraph.general: rhi texture atlas dimensions: 2048x2048

Bye 😉

NOTE: this article is a follow-up this this discussion, and presents a more up to date approach.

20 thoughts on “Qt 6 on the Raspberry Pi on eglfs”

  1. Hi Luca,

    did you manage to get audio works (with Alsa) ?
    I’ve always managed to get alsa works in previous build (last with buster on April’22) but at the moment i couldn’t with latest Buster or Bullseye (neither Qt 5 noe Qt 6)

    Thank you

    1. Hello,
      I’m sorry, I do not remember very well. I think Qt 5 worked properly with alsa. Qt 6 may require gstreamer instead, but I’m not sure. And I do not remember well if I tested it in Bullseye, probably only Buster.

  2. Hello Luca,

    I have been trying to compile qt 6.2.4 crossly on my hosy (ubuntu 22) for raspberry pi 4. I see some cmake problems. Like

    CMake Error at CMakeLists.txt:158 (add_subdirectory):
    The link interface of target “Platform” contains:

    Threads::Threads

    but the target was not found. Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

    CMake Error at cmake/FindWrapSystemHarfbuzz.cmake:56 (target_link_libraries):
    The link interface of target “WrapSystemHarfbuzz::WrapSystemHarfbuzz”
    contains:

    PkgConfig::PC_HARFBUZZ

    but the target was not found. Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

    Call Stack (most recent call first):
    cmake/QtFindPackageHelpers.cmake:130 (find_package)
    src/gui/configure.cmake:41 (qt_find_package)
    cmake/QtFeature.cmake:573 (include)
    src/CMakeLists.txt:12 (qt_feature_evaluate_features)

    Have you ever seen these before ?

    Could you please share your histroy or step that we can follow ?

  3. Hi Luca, very thanks for your sharing… I guess you can help on this:
    I use your toolchain for mac raspberry gcc 8.3, is build for armv8a but i’m on raspberry 3, i tried with simple hello world and it worked. My goal is building qt6 for crosscompile. So i have your toolchain, Raspberry 3 Buster, sysroot on my mac, i did toolchain.cmake but in any contest that i try i never found EGL and GLESv2 librarys.

    I have this li in my $SYSROOT/opt/vc/lib. Did you think that is for toolchain build for armv8? i don’t think due to hello world and other compilation work.

    also from my mac to compile for raspberry Opengl call from triangle .c i use:

    /opt/rpi/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-gcc -c triangle.c -o triangle.o -I/opt/rpi/sysroot/opt/vc/include
    /opt/rpi/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-gcc -o triangle triangle.o -lbrcmEGL -lbrcmGLESv2 -lvcos -lbcm_host -lvchiq_arm -L/opt/rpi/sysroot/opt/vc/lib

    Any suggestion?

      1. Configure summary:

        Building for: linux-g++ (arm, CPU features: neon)
        Compiler: gcc 8.3.0
        Build options:
        Mode …………………………….. release
        Optimize release build for size …….. no
        Fully optimize release builds (-O3) …. no
        Building shared libraries ………….. yes
        Using C standard ………………….. C11
        Using C++ standard ………………… C++17
        Using ccache ……………………… no
        Using new DTAGS …………………… yes
        Relocatable ………………………. yes
        Using precompiled headers ………….. yes
        Using LTCG ……………………….. no
        Target compiler supports:
        Extensions ……………………… NEON
        Sanitizers:
        Addresses ………………………. no
        Threads ………………………… no
        Memory …………………………. no
        Fuzzer (instrumentation only) …….. no
        Undefined ………………………. no
        Build parts ………………………. libs
        Qt modules and options:
        Qt Concurrent …………………….. yes
        Qt D-Bus …………………………. yes
        Qt D-Bus directly linked to libdbus …. yes
        Qt Gui …………………………… yes
        Qt Network ……………………….. yes
        Qt PrintSupport …………………… yes
        Qt Sql …………………………… yes
        Qt Testlib ……………………….. yes
        Qt Widgets ……………………….. yes
        Qt Xml …………………………… yes
        Support enabled for:
        Using pkg-config ………………….. yes
        udev …………………………….. no
        Using system zlib …………………. yes
        Zstandard support …………………. no
        Thread support ……………………. yes
        Common build options:
        Linker can resolve circular dependencies yes
        Qt Core:
        backtrace ………………………… yes
        DoubleConversion ………………….. yes
        Using system DoubleConversion …….. no
        GLib …………………………….. yes
        ICU ……………………………… yes
        Using system libb2 ………………… no
        Built-in copy of the MIME database ….. yes
        Tracing backend ……………………
        Logging backends:
        journald ……………………….. no
        syslog …………………………. no
        slog2 ………………………….. no
        PCRE2 ……………………………. yes
        Using system PCRE2 ………………. no
        CLONE_PIDFD support in forkfd ………. yes
        Qt Sql:
        SQL item models …………………… yes
        Qt Network:
        getifaddrs() ……………………… yes
        IPv6 ifname ………………………. yes
        libproxy …………………………. no
        Linux AF_NETLINK ………………….. yes
        OpenSSL ………………………….. yes
        Qt directly linked to OpenSSL …….. no
        OpenSSL 1.1 ………………………. yes
        DTLS …………………………….. yes
        OCSP-stapling …………………….. yes
        SCTP …………………………….. no
        Use system proxies ………………… yes
        GSSAPI …………………………… no
        Brotli Decompression Support ……….. no
        Qt Gui:
        Accessibility …………………….. yes
        FreeType …………………………. yes
        Using system FreeType ……………. yes
        HarfBuzz …………………………. yes
        Using system HarfBuzz ……………. yes
        Fontconfig ……………………….. yes
        Image formats:
        GIF ……………………………. yes
        ICO ……………………………. yes
        JPEG …………………………… yes
        Using system libjpeg …………… yes
        PNG ……………………………. yes
        Using system libpng ……………. yes
        Text formats:
        HtmlParser ……………………… yes
        CssParser ………………………. yes
        OdfWriter ………………………. yes
        MarkdownReader ………………….. yes
        Using system libmd4c …………… no
        MarkdownWriter ………………….. yes
        EGL ……………………………… no
        OpenVG …………………………… no
        OpenGL:
        Desktop OpenGL ………………….. no
        OpenGL ES 2.0 …………………… no
        OpenGL ES 3.0 …………………… no
        OpenGL ES 3.1 …………………… no
        OpenGL ES 3.2 …………………… no
        Vulkan …………………………… yes
        Session Management ………………… yes
        Features used by QPA backends:
        evdev ……………………………. yes
        libinput …………………………. no
        INTEGRITY HID …………………….. no
        mtdev ……………………………. no
        tslib ……………………………. no
        xkbcommon ………………………… yes
        X11 specific:
        XLib …………………………… yes
        XCB Xlib ……………………….. no
        EGL on X11 ……………………… no
        xkbcommon-x11 …………………… no
        xcb-sm …………………………. no
        QPA backends:
        DirectFB …………………………. no
        EGLFS ……………………………. no
        EGLFS details:
        EGLFS OpenWFD …………………… no
        EGLFS i.Mx6 …………………….. no
        EGLFS i.Mx6 Wayland ……………… no
        EGLFS RCAR ……………………… no
        EGLFS EGLDevice …………………. no
        EGLFS GBM ………………………. no
        EGLFS VSP2 ……………………… no
        EGLFS Mali ……………………… no
        EGLFS Raspberry Pi ………………. no
        EGLFS X11 ………………………. no
        LinuxFB ………………………….. yes
        VNC ……………………………… yes
        VK_KHR_display ……………………. yes
        QNX:
        lgmon ………………………….. no
        IMF ……………………………. no
        XCB:
        Using system-provided xcb-xinput ….. no
        GL integrations:
        GLX Plugin ……………………. no
        XCB GLX …………………….. no
        EGL-X11 Plugin ………………… no
        Windows:
        Direct 2D ………………………. no
        Direct 2D 1.1 …………………… no
        DirectWrite …………………….. no
        DirectWrite 3 …………………… no
        Qt Widgets:
        GTK+ …………………………….. no
        Styles …………………………… Fusion Windows
        Qt Testlib:
        Tester for item models …………….. yes
        Qt PrintSupport:
        CUPS …………………………….. no
        Qt Sql Drivers:
        DB2 (IBM) ………………………… no
        InterBase ………………………… no
        MySql ……………………………. no
        OCI (Oracle) ……………………… no
        ODBC …………………………….. no
        PostgreSQL ……………………….. no
        SQLite …………………………… yes
        Using system provided SQLite ……… no

        ERROR: Feature “opengl”: Forcing to “ON” breaks its condition:
        QT_FEATURE_opengl_desktop OR QT_FEATURE_opengl_dynamic OR QT_FEATURE_opengles2
        Condition values dump:
        QT_FEATURE_opengl_desktop = “OFF”
        QT_FEATURE_opengl_dynamic = “OFF”
        QT_FEATURE_opengles2 = “OFF”

        ERROR: The OpenGL functionality tests failed! You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2], QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.

        CMake Error at cmake/QtBuildInformation.cmake:80 (message):
        Check the configuration messages for an error that has occurred.
        Call Stack (most recent call first):
        cmake/QtBuildInformation.cmake:11 (qt_configure_print_summary)
        cmake/QtBuildInternals/QtBuildInternalsConfig.cmake:472 (qt_print_feature_summary)
        CMakeLists.txt:174 (qt_build_repo_end)

        — Configuring incomplete, errors occurred!

        1. I just found this in CMakeError.log:

          Performing C++ SOURCE FILE Test HAVE_EGL failed with the following output:
          Change Dir: /opt/rpi/qt6-rpi/CMakeFiles/CMakeTmp

          Run Build Command(s):/usr/local/bin/ninja cmTC_61c5e && [1/2] Building CXX object CMakeFiles/cmTC_61c5e.dir/src.cxx.o
          [2/2] Linking CXX executable cmTC_61c5e
          FAILED: cmTC_61c5e
          : && /opt/rpi/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-g++ –sysroot=/opt/rpi/sysroot -march=armv7-a -mfpu=neon -mfloat-abi=hard -Wl,-O1 -Wl,–hash-style=gnu -Wl,–as-needed -Wl,-rpath-link,/opt/rpi/sysroot/opt/vc/lib CMakeFiles/cmTC_61c5e.dir/src.cxx.o -o cmTC_61c5e && :
          /opt/rpi/rpi-gcc-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/cmTC_61c5e.dir/src.cxx.o: in function `main’:
          src.cxx:(.text+0x1a): undefined reference to `eglDestroyContext’
          collect2: error: ld returned 1 exit status
          ninja: build stopped: subcommand failed.

          Source file was:

          #include

          int main(int argc, char *argv[]) {
          EGLint x = 0; EGLDisplay dpy = 0; EGLContext ctx = 0;
          eglDestroyContext(dpy, ctx);
          }
          Performing C++ SOURCE FILE Test HAVE_GLESv2 failed with the following output:
          Change Dir: /opt/rpi/qt6-rpi/CMakeFiles/CMakeTmp

          Run Build Command(s):/usr/local/bin/ninja cmTC_85768 && [1/2] Building CXX object CMakeFiles/cmTC_85768.dir/src.cxx.o
          [2/2] Linking CXX executable cmTC_85768
          FAILED: cmTC_85768
          : && /opt/rpi/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-g++ –sysroot=/opt/rpi/sysroot -march=armv7-a -mfpu=neon -mfloat-abi=hard -Wl,-O1 -Wl,–hash-style=gnu -Wl,–as-needed -Wl,-rpath-link,/opt/rpi/sysroot/opt/vc/lib CMakeFiles/cmTC_85768.dir/src.cxx.o -o cmTC_85768 && :
          /opt/rpi/rpi-gcc-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/cmTC_85768.dir/src.cxx.o: in function `main’:
          src.cxx:(.text+0x10): undefined reference to `glUniform1f’
          /opt/rpi/rpi-gcc-8.3.0/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: src.cxx:(.text+0x18): undefined reference to `glClear’
          collect2: error: ld returned 1 exit status
          ninja: build stopped: subcommand failed.

          1. Yes, the errors seem pretty clear:

            undefined reference to `eglDestroyContext’
            undefined reference to `glUniform1f’
            undefined reference to `glClear’

            So you’ll need to link to EGL and GLESv2 for the test to succeed.

            1. Thanks for reply…!
              i did it with no good result.

              LIBEGL
              MBP-di-carmine:arm-linux-gnueabihf$ ls -la /opt/rpi/sysroot/usr/lib/arm-linux-gnueabihf/libEGL*
              lrwxr-xr-x 1 root wheel 11 Feb 10 16:02 /opt/rpi/sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so -> libEGL.so.1
              lrwxr-xr-x 1 root wheel 15 Feb 10 16:01 /opt/rpi/sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1 -> libEGL.so.1.0.0
              lrwxr-xr-x 1 root wheel 29 Feb 10 16:00 /opt/rpi/sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 -> ../../../opt/vc/lib/libEGL.so

              LIBGLESv2
              MBP-di-carmine:arm-linux-gnueabihf$ ls -la libGLESv2*
              lrwxr-xr-x 1 root wheel 14 Feb 10 16:11 libGLESv2.so -> libGLESv2.so.2
              lrwxr-xr-x 1 root wheel 18 Feb 10 16:11 libGLESv2.so.2 -> libGLESv2.so.2.0.0
              lrwxr-xr-x 1 root wheel 31 Feb 10 15:18 libGLESv2.so.2.0.0 -> sysroot/opt/vc/lib/libGLESv2.so

              do you see something wrong here?

              1. No, but the problem seemed not to be a missing file, but a symbol that could not be found. The compilation line was not linking to EGL or GLESv2.

    1. Hello, if you are talking about the toolchians yes, probably my fault, sorry. Those are just links to the internal related articles. The articles are available in the blog. I’ll fix the links though, thanks for letting me know.

      1. I make cross compile using your gcc toolchain
        I just has the main issue here :

        — Could NOT find EGL (missing: HAVE_EGL) (found version “1.5”)

        I install all EGLdrivers (mesa , brcm)
        and pass all paths to toochain.cmake
        all packages can be found else EGL, GLES

        1. No idea sorry. If configure cannot find EGL, it may mean the env is not setup properly. You can probably check for the exact error in the logs.

Leave a Reply

Your email address will not be published. Required fields are marked *