Building Qt 6.6 for Raspberry Pi on Raspberry Pi OS

Qt is a popular cross-platform application framework that enables developers to create user interfaces and applications that can run on various platforms, including the Raspberry Pi. This tutorial provides you a step-by-step guide on how to build an up-to-date Qt 6.6 release from source with proper hardware acceleration support for Raspberry Pi on Raspberry Pi OS, both 32-bit and 64-bit, based on Debian 12 Bookworm release.

Updated as of Qt 6.6 release 6.6.3, released 21.03.2023.

Raspberry Pi CPU closeup

Guide on how to build Qt 6.6 for use on a Raspberry Pi running Raspberry Pi OS based on Debian 12 Bookworm.

Note: If you are coming from Qt 5, note that the configuration and build differs quite a lot from how Qt 5 was built as the build system is now using cmake and ninja, instead of the older qmake and make combo.

Note: The procedure is exactly the same for both 32-bit or 64-bit versions of Raspberry Pi OS, just adjust any architecture specific paths accordingly.

This tutorial is written for the split sources version of Qt 6.6 release, instead of the all sources in one. This makes it much faster to get up and running with only the components you actually need. Building Qt 6 for and on the Raspberry Pi is still pretty straightforward, there are a couple Pi specific configurations that needs to be made, but in short it consist of the following simple steps:

  1. Configure Raspberry Pi graphics system to use Mesa/Vulkan driver
  2. Installing all required build and runtime dependencies for Qt base
  3. Installing any optional build and runtime dependencies for Qt base
  4. Prepare Qt 6.6 base sources
    1. Downloading Qt 6.6 base sources
    2. Checking the Qt 6.6 base source package integrity
    3. Extract the base sources
  5. Configuring the Qt 6.6base build
  6. Compiling Qt 6.6 base
  7. Installing the Qt 6.6 base
  8. Continue to installing any Qt submodules

And for any Qt 6.6 submodules the procedure is about the same as for the base package:

  1. Install required build and runtime dependencies
  2. Install optional build and runtime dependencies
  3. Prepare sources
    1. Download submodule source archive
    2. Check integrity of submodule source archive
    3. Extract submodule source archive
  4. Configure submodule for building
  5. Build submodule
  6. Install submodule
  7. Select another submoule and goto step 1

Prepare the build tools required

Essentials build packages

As we need to be able to compile and build software from source, make sure all the essential build & compiler tools, cmake and ninja are installed with:

apt install build-essential cmake ninja-build

Install required build dependencies

You will need to install plenty of packages to be able to build Qt 6.6. Some of the Qt 6.6 features are optional and can be either left out or included, depending on your particular needs. For example support for various databases (PostgreSQL, MySQL/MariaDB) and if you don't need a specific feature you can skip building the support. Or the other way around, if you need a specific feature you might need to install more development packages.

First, start by updating your apt package cache so everything is fresh:

apt update

Then continue with required package installation below.

Minimum required development packages
Development packageInformation
libfontconfig1-devFont configuration library
libharfbuzz-devOpenType text shaping engine
libdbus-1-devD-Bus library
libfreetype6-devFont engine library
libicu-devUnicode library
libinput-devInput device handling
libxkbcommon-devXKB compiler library
libsqlite3-devsqlite3 database driver
libpng-devPNG Image support
libssl-devOpenSSL support
libjpeg-devJPEG Image support
libglib2.0-devglib mainloop support

Install all the required development packages with:

apt install libfontconfig1-dev libharfbuzz-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libsqlite3-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev

Raspberry Pi graphics environment and driver options

With Qt 6 you will be using the Mesa and the V3D, VC4 drivers only as support for the proprietary EGL blobs from Broadcom has been dropped in both Raspberry Pi OS and Qt 6.

Graphics driver options
Graphics driverRequired package(s)Information
V3D and VC4 driverlibgles2-mesa-dev libgbm-dev libdrm-devQT_FEATURE_kms=ON
QT_FEATURE_opengles2=ON
QT_FEATURE_opengles3=ON

Vulkan support with V3D driver

Only on Raspberry Pi 4 & 5

libvulkan-dev vulkan-toolsQT_FEATURE_vulkan=ON
X11See belowQT_FEATURE_xcb=ON
WaylandSee belowNote that Wayland support is in qtwayland submodule.

 

Optional base feature dependencies

Some features are not strictly required but might still be nice to have, for example support for the webp image format is optional, but these days it is already widely used so might be good to include.

See the table below for a list of some optional features and the required development packages you need to install.

Optional features for base Qt
Optional featurePackages to installConfigure option
   
Support for database PostgreSQLlibpq-dev 
Support for database  MariaDB/MySQLlibmariadb-dev libmariadb-dev-compat 
Printing support using CUPSlibcups2-dev 
X11 supportlibx11-dev libxcb1-dev libxext-dev libxi-dev libxcomposite-dev libxcursor-dev libxtst-dev libxrandr-dev libx11-xcb-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-util0-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev libxcb-xinput-dev libxcb-cursor-devQT_FEATURE_xcb=ON
Waylandlibwayland-dev 
libzstdlibzstd-dev 
GTK 3 Theme supportlibgtk-3-dev 
Accessibilitylibatspi2.0-dev 

SCTP [1][2]

Stream Control Transmission Protocol

libsctp-devQT_FEATURE_LABEL_sctp

Install any required packages for the feature you require from the above table with apt install.

 

Building Qt 6.6 base

Qt Base provides the core parts of Qt and needs to be built and installed before anything else.

Download Qt 6.6 base sources

wget https://download.qt.io/official_releases/qt/6.6/6.6.3/submodules/qtbase-everywhere-src-6.6.3.tar.xz

Configure, build and install Qt 6.6 base

Extract the sources:

tar xf qtbase-everywhere-src-6.6.3.tar.xz

Create a build directory:

mkdir qtbasebuild && cd qtbasebuild

Optional: Create a cmake toolchain file

You might need to make a cmake toolchain file in case you are building for some other type of architecture than the one you are building on, for example you are going to run Qt on the armv6 based Pis but build on something faster (armv7 or armv8).

Note: This is not needed if the Qt 6 build will be run on the same architecture as the building. For example, you are building on 32-bit armv7 Pi and intend to run Qt on armv7 or above then toolchain file is not required.

To create a cmake toolchain file, tc.cmake, fire up your favorite editor. Create the file somewhere that does not get deleted, for example in the install prefix you use, as it will be referenced by the Qt build files when installed. The contents for the file is, depending on target architecture (Note: only armv7 has been tested):

CMAKE_TOOLCHAIN_FILE Examples
ArchitectureToolchain file contents
For armv6
set(CMAKE_CROSSCOMPILING FALSE)
set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR armv6) set(TARGET armv6-linux-eabi)
For armv7
set(CMAKE_CROSSCOMPILING FALSE)
                                set(CMAKE_SYSTEM_NAME Linux)
                                set(CMAKE_SYSTEM_PROCESSOR armv7)
                                set(TARGET armv7-linux-eabi)
For armv8
set(CMAKE_CROSSCOMPILING FALSE)
                                set(CMAKE_SYSTEM_NAME Linux)
                                set(CMAKE_SYSTEM_PROCESSOR armv8)
                                set(TARGET armv8-linux-eabi)
For aarch64

 

TBA

 

 

Configuration options

Qt can be customized in many ways when building, this table shows some options that you can use when configuring the  build.

OptionDescription
QT_FEATURE_opengles2=ONUse OpenGL ES 2.0
QT_FEATURE_opengles3=ONUse OpenGL ES 3.0
QT_FEATURE_kms=ONUse Kernel Mode Setting
QT_FEATURE_vulkan=ONUse Vulkan driver
QT_QPA_DEFAULT_PLATFORM=eglfsSet default platform plugin to eglfs
BUILD_WITH_PCH=OFFDisable precompiled headers

 

Configure the Qt 6.6 build

Then run the configuration (adjusting prefix if needed, add/remove any configuration options as needed, remove CMAKE_TOOLCHAIN_FILE parameter if not used, etc):

cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/Qt/6.6 \
-DQT_FEATURE_opengles2=ON \
-DQT_FEATURE_opengles3=ON \
-DQT_FEATURE_kms=ON \
-DQT_FEATURE_xcb=ON \
-DQT_FEATURE_vulkan=ON \
-DCMAKE_TOOLCHAIN_FILE=tc.cmake \
-DQT_AVOID_CMAKE_ARCHIVING_API=ON ../qtbase-everywhere-src-6.6.3

Check the configuration summary output that everything required was successfully detected, and if so, you can start the build of Qt.

Build Qt 6.6 base

Next up is actually compiling the sources, that we will do with the following command, adjust the example parallel build (4) as you see fit.

Note: On the 1 core or low memory systems a parallel build is not recommended.

cmake --build . --parallel 4

Install Qt 6.6 base

When the build has successfully finnished, the next step is to install the result to the system. To install the compiled Qt, run:

cmake --install .

Building Qt Documentation

QDoc is required for building and installing documentation for use in various GUI tools. QDoc is part of the qttools submodule and obviously requires Qt itself to build. Documentation can be built afterwards from the build tree so if you do need documentation then don't remove any build results just yet.

Documentation is built with:

cmake --build . --parallel 4 --target docs

And installed with:

cmake --build . --target install_docs

Building Qt submodules

You can quickly configure, build and install the Qt submodules with (why not do it in simple for loop, I'll leave that as an excerise for the reader!):

/opt/Qt/6.6/bin/qt-configure-module . && cmake --build . --parallel 4 && cmake --install .

For a more in-depth tutorial on building sub-modules, see the Qt sub-module building tutorial.