Building the QtWebEngine Qt 5 module takes a lot of time, space and memory. It is highly recommended to build qtwebengine separately from base Qt 5.
QtWebEngine is a very large and complicated Qt module as it contains the Chrome browser engine. It takes a lot of space, memory and time to build and therefore it is high recommended to be built separately from rest of Qt. It can be built natively on the Raspberry Pi but you need one of the more powerful models with plenty of memory. With the 4GB or 8GB Raspberry Pi 4 models it is fully possible to build, but you might still need to enable swap and also limit the amount of parallel builds the ninja build tool (that qtwebengine uses internally for building) is allowed to use.
Start by first building the base Qt 5 framework you need (You can follow the guide for Qt 5.12 or Qt 5.15) and make sure it works ok first, then you can build the qtwebengine module. The examples below will be using Qt version 5.15.7 (See release notes here) so if you are using any other version, just adjust the paths to correspond to the version of Qt that you are using.
Download the sources for QtWebEngine
You have two choices here, either download the the release archives or use qtwebengine from git.
The archives are easier and take less space but unfortunately getting old. Git repositories takes up more space and needs a bit more work.
a) Download release archive
b) Use git repository
git clone https://invent.kde.org/qt/qt/qtwebengine.git git checkout -t remotes/origin/5.15.7 git submodule update --init
Install required and any optional build dependencies
|Required||flex bison gperf libre2-dev libnss3-dev python2 nodejs||
These tools and libraries are required for any build.
git version requires nodejs
|Required for X11 support||libdrm-dev libxdamage-dev libxkbfile-dev||If you need qpa-xcb/X11 support you need these|
|Optional||libxml2-dev libxslt1-dev libminizip-dev libjsoncpp-dev liblcms2-dev libevent-dev libprotobuf-dev protobuf-compiler libwebp-dev libpoppler-cpp-dev||These are optional but can be nice to have for additional support|
|Optional system build tools||ninja-build re2c||You can speed up the build by using system ninja build tool, otherwise it will be built first.|
Optional media support.
Note: Unusable versions in Raspbian Buster
These add support for opus and vpx media.
Versions in Bullseye will work.
Unfortunately the versions available in Raspberry Pi OS/Raspbian Buster are too old.
Setup sources for building
Extract the source archive and create a separate build directory.
Disable jumbo build in 5.15
Note: This is not needed if building on Bullseye
We had no luck with the default jumbo build system in 5.15, compiling failed with obscure errors that made no sense, so we need to disable it.
Adjust the parameter with help of sed with the command (adjust paths if you need to) or use your favorite editor to change the option:
sed -i -e 's|use_jumbo_build=true|use_jumbo_build=false|' ../qtwebengine-everywhere-src-5.15.7/src/buildtools/config/common.pri
Configure QtWebEngine for building
/opt/Qt/5.15.7/bin/qmake ../qtwebengine-everywhere-src-5.15.7 -- -no-webengine-geolocation
If all goes well, you should be presented with a summary that looks similar to this (Yours does not need to match 100% as it depends on what packages you have installed and on any options given):
- Example configuration summary for QtWebEngine 5.12.10
- Example configuration summary for QtWebEngine 5.15.7
All is well as long as the configuration does not give errors. Just make sure that any extra features you might need are found and enabled.
Compiling QtWebEngine 5
Now if everything is properly detected (and no mention about QtWebEngine not being built), proceed to building.
Start the build
We must limit the amount of parallel builds, especially on anything less than 8GB, by limiting ninja parallel builds with NINJAJOBS to 4 or less. On 4GB you need to go down to 2 jobs.
Invoke make with:
make -j4 NINJAJOBS=-j4
Building will take a very long time.
When (and if) the build is complete, the installation part is easy, just:
And you are done. Now you should be able to use QtWebEngine in your Qt and QtQuick applications.
Possible build issues with QtWebEngine and their solutions
The following table has collected some of the problems and build issues found with QtWebEngine
|QtWebEngine version||Problem description||Details, Solution or workaround|
Internal Compiler Error, gcc 8.3.0
internal compiler error: in convert_move, at expr.c:218 static void exec_ops(const Op* ops, const void** args,
a) Use ARMv7 build of Qt
b) Patch the source to disable optimization with a gcc pragma in source:
#pragma GCC optimize ("O0")
|5.15.2||fatal error: xcb/dri3.h: No such file or directory||
Missing required development package that configure scripts does not check for.
qtwebengine-everywhere-src-5.15.2/src/3rdparty/chromium/ui/gl/gl_bindings_autogen_egl.h:201:5: error: ‘EGLDeviceEXT’ has not been declared
Fails to build against Qt built with Broadcom EGL.
Build against Qt 5.15.2 build with VC4/KMS instead of Broadcom EGL.
Use Qt & QtWebEngine 5.12.10
Failed build, kernel errors in dmesg:
Out of memory: Killed process 125689 (cc1plus)
|You run out of memory, limit the amount of parallel build jobs.|