Introduction to QtWebEngine
QtWebEngine integrates
chromium's web capabilities into
Qt. It ships with its own copy of ninja which it uses for the build
if it cannot find a system copy, and various copies of libraries
from ffmpeg, icu, libvpx, and zlib (including libminizip) which
have been forked by the chromium
developers.
This package and browsers using it may be useful if you need to use
a website designed for google chrome, or chromium, browsers.
Warning
QtWebEngine uses a forked copy of chromium, and is therefore
vulnerable to many issues found there. The Qt developers have
always preferred to make releases at the same time as the rest of
Qt (rather than adding emergency fixes), but with stable versions
getting released after the current development version. Now that
they are keen to move to Qt6, the 5.15.3 and later Qt-5.15
releases are initially only available to paying customers.
QtWebEngine is something of an exception because of its LGPL
licence, but getting the git sources (with the forked chromium
submodule) to a position where they will successfully build on a
current BLFS system can take a lot of effort and therefore
updates to the book may be delayed.
It seems likely that future 5.15-series versions will also be
released long after the chromium vulnerabilities are known, but
fixes for QtWebEngine can be found in git and the editors take
the view that known vulnerabilities in browsers should be fixed.
The tarball linked to below was created from the 5.15 git branch
and the 87-branch of the chromium submodule (which is forked from
chromium). See the GIT-VERSIONS file in the tarball for details
of the latest commits.
This package is known to build and work properly using an LFS-10.1
platform.
Note
By default, ninja will use all online CPUs +2 (if at least 4
exist), even if they are not available to the current task
because the build terminal has been restricted with 'taskset'. To
work around this, see the Command Explanations below.
Unusually, the shipped GN build system (used to create the Ninja
files) requires a static libstdc++.a
although the installed libraries
correctly use the shared version. If that static library is not
present, the build will fail quite quickly. Please note that if
you try to build webengine as part of Qt and the static library is not available,
that build will either complete without installing webengine, or
else fail during the install (both variants have been observed in
5.12.0).
Package Information
Additional Downloads
qtwebengine Dependencies
Required
nodejs-14.16.1, NSS-3.63, Python-2.7.18, and Qt-5.15.2
Recommended
Note
If these packages are not installed, the build process will
compile and install its own (perhaps older) version, with the
side effect of increasing build and installed disk space and
build time.
either alsa-lib-1.2.4 or PulseAudio-14.2 (or both), FFmpeg-4.4,
ICU-68.2, libwebp-1.2.0,
libxslt-1.1.34, and Opus-1.3.1
Optional
libevent-2.1.12, Poppler-21.03.0, jsoncpp,
libsrtp, snappy
User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/qtwebengine
Installation of qtwebengine
Note
Unlike version 5.15.2, the chromium-derived build system now
needs python to be
available and to be python2. In BLFS-10.1 the creation of the
python symlink was removed as a step towards eventually getting
rid of python2 (other old packages which need python2 usually
work by invoking python2). If you are still using an earlier
version of BLFS where /usr/bin/python
exists, you can skip the
commands to create the symlink, and to later remove it.
First, as the root
user, create the
python symlink:
ln -svf /usr/bin/python{2,}
Now apply a patch to fix several issues that can prevent the build
working:
patch -Np1 -i ../qtwebengine-20210401-build_fixes-1.patch
Although the patch has ensured that git is not invoked during the
build, the build system has labyrinthine rules of byzantine
complexity, and in particular trying to build without two
.git
directories will lead to it
eventually falling into unexpected and unbuildable code which
references a private header that has not been created. Avoid this
by creating the required directories:
mkdir -pv .git src/3rdparty/chromium/.git
Because this version of qtwebengine is aimed at a later release
than the current public releases, change it to build for qt-5.15.2
using a sed:
sed -e '/^MODULE_VERSION/s/5.*/5.15.2/' -i .qmake.conf
Now, ensure that the local headers are available when not building
as part of the complete Qt-5.15.2:
find -type f -name "*.pr[io]" |
xargs sed -i -e 's|INCLUDEPATH += |&$$QTWEBENGINE_ROOT/include |'
Next, allow the pulseaudio library to be linked at build time,
instead of run time. This also prevents an issue with newer
pulseaudio:
sed -e '/link_pulseaudio/s/false/true/' \
-i src/3rdparty/chromium/media/media_options.gni
Finally, fix a change in the build system which allows its
developers to pass e.g. -j20 to make (for quick tests of some
areas) but breaks the build with LFS's use of the NINJAJOBS
environment variable:
sed -i 's/NINJAJOBS/NINJA_JOBS/' src/core/gn_run.pro
If an older version of the package's main library has been
installed, when the package is built separately it will link to
that in preference to its own not-yet-installed version, and fail
because of missing symbols. Prevent that by, as the root
user, moving the symlink out of the way:
if [ -e ${QT5DIR}/lib/libQt5WebEngineCore.so ]; then
mv -v ${QT5DIR}/lib/libQt5WebEngineCore.so{,.old}
fi
Install qtwebengine by running the
following commands:
mkdir build &&
cd build &&
qmake .. -- -system-ffmpeg -webengine-icu &&
make
This package does not come with a test suite.
Now, as the root
user:
make install
Remove references to the build directory from installed library
dependency (prl) files by running the following commands as the
root
user:
find $QT5DIR/ -name \*.prl \
-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;
Finally, as the root
user, remove
the python symlink:
rm -v /usr/bin/python
Command Explanations
qmake: This will
build the included copy of ninja
if it is not already installed and use it to configure the build.
-- -system-ffmpeg
-webengine-icu: If any options are passed to qmake
they must come after '--' which must follow '..' that points to the
main directory. The options here cause it to use system ffmpeg and
system icu. If built as part of full Qt5, the system icu is
automatically used (only) by Qt5Core if it is available, but unless
this option is used webengine will always use its shipped copy of
icu, adding time and space to the build.
NINJAJOBS=4 make
: If you patched system
ninja in LFS to recognize the NINJAJOBS environment variable, this
command will run system ninja with the specified number of jobs
(i.e. 4). There are several reasons why you might want to do this:
-
Building on a subset of CPUs allows measuring the build time
for that number of processors or to run other CPU-intensive
tasks on other cores.
-
Improving the build speed on a less-well endowed 4-core
machine. On a machine with a powerful CPU and plenty of RAM,
running N+2 jobs (the ninja default for 4+ cores) for the
large working sets of the C++ compiles in this package is
typically only marginally faster than running N jobs at a
time. But for a machine with less memory it can be much
slower.
-
Reducing the number of cores being used on long running, CPU
intensive packages may alleviate heat problems.