Qt 6 on the Raspberry Pi on eglfs
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.
I configured this build in the simplest form. To start, I want to use eglfs on OpenGL ES.
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:
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 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.
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.
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.
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.
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
NOTE: this article is a follow-up this this discussion, and presents a more up to date approach.