Skip to content

Building QtWebKit on Linux

Vitaly Slobodin edited this page Jan 10, 2020 · 35 revisions

You need to install the next dependencies:

  • Qt >= 5.4 (Core, Gui, Network, Sql, OpenGL, Test, Widgets, Positioning, Sensors)
    • For QML API: Declarative, WebChannel (or you can disable it with -DENABLE_WEBKIT2=OFF cmake flag)
  • CMake >= 2.8.12 (>= 3.2 is recommended)
  • ninja
  • sqlite >= 3.6.16
  • ICU >= 52.1
  • ruby >= 1.9
  • perl >= 5.10.0
  • python 2.7.x
  • bison >= 2.1
  • flex >= 2.5.34
  • gperf >= 3.0.1
  • libxml2 >= 2.8.0 (2.6.x will probably work)
  • libxslt >= 1.1.7
  • libjpeg v8 or v9 (IJG) or libjpeg-turbo
  • libpng
  • zlib
  • libhyphen
  • glib >= 2.36 (gio, gobject)
  • gstreamer >= 1.0.3 (app, pbutils, video, mpegts, tag, audio, fft); you also need GStreamer 1.0 plugins for codec support

Optional dependencies:

  • fontconfig
  • libwebp

Q: Why do you have so many dependencies?

A: See FAQ

For Ubuntu >= 18.04 use the following command:

sudo apt-get build-dep libqt5webkit5

For Fedora >= 30 use the following command:

sudo dnf install qt5-devel cmake ninja-build sqlite-devel libicu-devel ruby perl bison flex gperf libxml-devel libxslt-devel libjpeg-turbo-devel libpng-devel zlib-devel hyphen-devel glib2-devel gstreamer1-devel qt5 qt5-qtbase-private-devel

You can then build QtWebKit with cmake:

mkdir -p WebKitBuild/Release
cd WebKitBuild/Release
cmake -DPORT=Qt -DCMAKE_BUILD_TYPE=Release ../..
make -jN # Replace N with number of your CPU cores
sudo make install

If you are not using system-wide installation of Qt, you should add -DQt5_DIR=$your_Qt_path/lib/cmake/Qt5 to cmake arguments, e.g.

cmake -DPORT=Qt -DCMAKE_BUILD_TYPE=Release \
    -DQt5_DIR=/opt/Qt5.8.0/5.8/gcc_64/lib/cmake/Qt5 ../..


cmake -DPORT=Qt -DCMAKE_BUILD_TYPE=Release \
    -DQt5_DIR=/usr/local/Qt-5.11.0/lib/cmake/Qt5 ../..

Note: this manual previously suggested using CMAKE_PREFIX_PATH, but it may cause build errors related to misdetection of ICU libraries with Qt SDK 5.8.0 and 5.9.0


Cross-compilation with CMake is described in official CMake documentation. Basically, you need CMake toolchain file (for example, see ToolchainMIPS.cmake in the root of this repository), and all required dependencies compiled for your target. In order to reduce number of dependencies, you may want to disable some features.

Building for running test suite

If you're contributing to QtWebKit, optionally run the Tools/Scripts/update-qtwebkit-libs script (see JHBuild) to build all dependencies inside the source tree, in order to get reproducible test results. Then use the build-webkit script to get separate debug/release builds:

Tools/Scripts/build-webkit --qt --release  # or --debug


Currently you have to install QtWebKit in order to build your applications against it. Installation prefix is controlled by CMAKE_INSTALL_PREFIX variable, you may even set it to your Qt prefix (warning: it will replace existing QtWebKit files if you have one installed!).

Run the following command to perform installation:

cd WebKitBuild/Release && sudo make install

or if you build with ninja (default behavior of build-webkit, if ninja is installed):

cd WebKitBuild/Release && sudo ninja install

Installation Troubleshoot

If you are building with ninja and see error like this:

CMake Error at Source/WebKit/cmake_install.cmake:129 (FILE):
  file INSTALL cannot find
Call Stack (most recent call first):
  Source/cmake_install.cmake:94 (INCLUDE)
  cmake_install.cmake:37 (INCLUDE)

run the next command:

sed -ie 's|Source/WebKit/CMakeFiles/CMakeRelink\.dir|lib|' Source/WebKit/cmake_install.cmake
sed -ie 's|Source/WebKit/qt/declarative/CMakeFiles/CMakeRelink\.dir|imports/QtWebKit|' Source/WebKit/qt/declarative/cmake_install.cmake
sed -ie 's|Source/WebKit/qt/declarative/experimental/CMakeFiles/CMakeRelink\.dir|imports/QtWebKit/experimental|' Source/WebKit/qt/declarative/experimental/cmake_install.cmake

Another solution is building with CMAKE_BUILD_WITH_INSTALL_RPATH=ON, but in this case binaries won't run before installation without setting LD_LIBRARY_PATH

Building only JSC

To build only JSC, replace build-webkit with build-jsc

Use this command to run JSC tests:

Tools/Scripts/run-layout-jsc -t LayoutTests/ -j build/qt-jsc/Release/bin/jsc -r results
You can’t perform that action at this time.