QtWebEngine/Qt6Build: Difference between revisions
m (fix spacing) |
m (remove extra 'skip webengine') |
||
(6 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
Qt builds can be done in ''top level'' manner, meaning that you clone qt5 main repository (git://code.qt.io/qt/qt5.git), | Qt builds can be done in ''top level'' manner, meaning that you clone qt5 main repository (git://code.qt.io/qt/qt5.git), | ||
which then initializes all the qt modules as sub-modules, configures and builds everything in one go. | which then initializes all the qt modules as sub-modules, configures all the modules and builds everything in one go. | ||
However, there is also the alternative way, so called ''module build'', which is more robust as it builds | However, there is also the alternative way, so called ''module build'', which is more robust as it configures, builds | ||
and installs each qt module separately. | and installs each qt module separately. | ||
This guide uses both approaches, first it clones minimum subset of modules required for QtWebEngine and compiles | This guide uses both approaches, first it clones minimum subset of modules required for QtWebEngine and compiles | ||
all modules required for webengine build in ''top level'' manner. Then it builds | all modules required for webengine build in ''top level'' manner. Then it builds webengine module separately, so we | ||
are able to focus on webenigne build issues only. | are able to focus on webenigne build issues only. | ||
Line 31: | Line 31: | ||
==Obtain the Qt6 source code== | ==Obtain the Qt6 source code== | ||
Select the location for the source code and checkout the source: | Select the location for the source code and checkout the qt6 source: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
git clone git://code.qt.io/qt/qt5.git qt6 | git clone git://code.qt.io/qt/qt5.git qt6 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Select branch== | |||
Let's assume we want to compile latest Qt 6.8. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cd | cd qt6 | ||
git | git checkout origin/6.8 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | ==Initialize all required modules== | ||
Starting with Qt 6.8 you can simply after cloning qt5 repository and selecting branch call 'init-repository' cmake script. This will also setup all the required submodules. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
./init-repository --module-subset=qtbase,qtshadertools,qtdeclarative,qtwebengine --no-resolve-deps | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{note|On Windows platform you should use 'init-repository.bat' instead of 'init-repository' command.}} | |||
==Shadow build== | ==Shadow build== | ||
It is a common practice to compile the project in separate build directory instead of doing in-source build, therefore we create | It is a common practice to compile the project in separate build directory instead of doing in-source build, therefore we create build directory: | ||
{{note|On Windows platform you should use 'md' instead of 'mkdir' command}} | {{note|On Windows platform you should use 'md' instead of 'mkdir' command}} | ||
Line 79: | Line 65: | ||
mkdir build | mkdir build | ||
cd build | cd build | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Configure and build | ==Configure top level build and build required submodules== | ||
From our | From our 'build' directory we call the configure from qt6 'source' directory to make prefix build, which means that we will compile and than install to the specific installation directory defined with 'prefix' argument. | ||
On '''Linux''' the configure command line for the release builds | {{note|We will add '-skip qtwebengine' argument to configure call as we want to do qtwebenigne build separately.}} | ||
On '''Linux''' the configure command line for the release builds might look like: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
.. | ../configure -release -nomake tests -nomake examples -no-pch -linker mold -skip qtwebengine -prefix /opt/qt/6.8 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{note|To speed up linking time for WebEngine we decided to use | {{note|To speed up linking time for WebEngine we decided to use mold linker.}} | ||
On '''Windows''' the configure command line for the release build | On '''Windows''' the configure command line for the release build might look like: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
..\configure.bat -release -nomake tests -nomake examples -no-pch -skip qtwebengine -prefix C:\opt\qt\6.8 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 105: | Line 91: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
../configure -release -framework -release -nomake tests -nomake examples -no-pch -skip qtwebengine -prefix /opt/qt/6.8 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 112: | Line 97: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
../configure -release -framework -nomake tests -nomake examples -no-pch -skip qtwebengine -prefix /opt/qt/6.8 -- -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{note| For other configure options please refer to the configure guide https://doc.qt.io/qt-6/configure-options.html}} | {{note| For other configure options please refer to the configure guide https://doc.qt.io/qt-6/configure-options.html}} | ||
To build and install | To build and install modules you just need to call cmake: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 127: | Line 111: | ||
{{note | On Windows in case of debug and release build please use "ninja install" instead of "cmake --install ." due to cmake [https://gitlab.kitware.com/cmake/cmake/-/issues/21475 issue]}} | {{note | On Windows in case of debug and release build please use "ninja install" instead of "cmake --install ." due to cmake [https://gitlab.kitware.com/cmake/cmake/-/issues/21475 issue]}} | ||
==Configure and build | ==Configure and build QtWebEngine module== | ||
To configure and build | To configure and build QtWebEngine module we use the '''qt-configure-module wrapper''' script from the installed in previous step Qt. | ||
{{note|On Windows you might want to call 'C:\opt\qt\6. | {{note|On Windows you might want to call 'C:\opt\qt\6.8\bin\qt-cofigure-module.bat' instead of 'qt-cofigure-module'}} | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
mkdir qtwebengine | |||
cd qtwebengine | cd qtwebengine | ||
/opt/qt/6. | /opt/qt/6.8/bin/qt-configure-module ../../qtwebengine | ||
cmake --build . --parallel | cmake --build . --parallel | ||
cmake --install . | cmake --install . | ||
cd .. | cd .. | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 12:44, 16 September 2025
Building Qt6 WebEngine from Source
Please check platform notes for required dependencies https://doc.qt.io/qt-6/qtwebengine-platform-notes.html.
Qt builds can be done in top level manner, meaning that you clone qt5 main repository (git://code.qt.io/qt/qt5.git), which then initializes all the qt modules as sub-modules, configures all the modules and builds everything in one go. However, there is also the alternative way, so called module build, which is more robust as it configures, builds and installs each qt module separately.
This guide uses both approaches, first it clones minimum subset of modules required for QtWebEngine and compiles all modules required for webengine build in top level manner. Then it builds webengine module separately, so we are able to focus on webenigne build issues only.
Note: Compiling each module separately has advantage that you can see configure and compilation issues just for given module, meaning that you can install missing dependencies and just reconfigure and recompile the problematic module instead of rerunning configuration for all modules.
Open the build shell
All the build commands we execute in a build shell / terminal.
On Windows platform Developer Command Prompt is required, therefore for example for Visual Studio Build Tools 2022 the correct setup requires:
call "C:\Program File (x86)\Microsoft Visial Studio\2022\BuildTools\VC\Auxilary\Build\vcvarsall.bat" amd64
Note: The location of the script may vary please refer to the Microsoft documentation.
Obtain the Qt6 source code
Select the location for the source code and checkout the qt6 source:
git clone git://code.qt.io/qt/qt5.git qt6
Select branch
Let's assume we want to compile latest Qt 6.8.
cd qt6
git checkout origin/6.8
Initialize all required modules
Starting with Qt 6.8 you can simply after cloning qt5 repository and selecting branch call 'init-repository' cmake script. This will also setup all the required submodules.
./init-repository --module-subset=qtbase,qtshadertools,qtdeclarative,qtwebengine --no-resolve-deps
Note: On Windows platform you should use 'init-repository.bat' instead of 'init-repository' command.
Shadow build
It is a common practice to compile the project in separate build directory instead of doing in-source build, therefore we create build directory:
Note: On Windows platform you should use 'md' instead of 'mkdir' command
mkdir build
cd build
Configure top level build and build required submodules
From our 'build' directory we call the configure from qt6 'source' directory to make prefix build, which means that we will compile and than install to the specific installation directory defined with 'prefix' argument.
Note: We will add '-skip qtwebengine' argument to configure call as we want to do qtwebenigne build separately.
On Linux the configure command line for the release builds might look like:
../configure -release -nomake tests -nomake examples -no-pch -linker mold -skip qtwebengine -prefix /opt/qt/6.8
Note: To speed up linking time for WebEngine we decided to use mold linker.
On Windows the configure command line for the release build might look like:
..\configure.bat -release -nomake tests -nomake examples -no-pch -skip qtwebengine -prefix C:\opt\qt\6.8
On Mac the configure command line for the release framework builds might look like:
../configure -release -framework -release -nomake tests -nomake examples -no-pch -skip qtwebengine -prefix /opt/qt/6.8
or Mac universal build :
../configure -release -framework -nomake tests -nomake examples -no-pch -skip qtwebengine -prefix /opt/qt/6.8 -- -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
Note: For other configure options please refer to the configure guide https://doc.qt.io/qt-6/configure-options.html
To build and install modules you just need to call cmake:
cmake --build . --parallel
cmake --install .
Note: On Windows in case of debug and release build please use "ninja install" instead of "cmake --install ." due to cmake issue
Configure and build QtWebEngine module
To configure and build QtWebEngine module we use the qt-configure-module wrapper script from the installed in previous step Qt.
Note: On Windows you might want to call 'C:\opt\qt\6.8\bin\qt-cofigure-module.bat' instead of 'qt-cofigure-module'
mkdir qtwebengine
cd qtwebengine
/opt/qt/6.8/bin/qt-configure-module ../../qtwebengine
cmake --build . --parallel
cmake --install .
cd ..