Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
QtWebEngine/Qt6Build: Difference between revisions
m (add more hints) |
(add windows notes) |
||
Line 11: | Line 11: | ||
meaning that you can install missing dependencies and just reconfigure and recompile the problematic module instead | meaning that you can install missing dependencies and just reconfigure and recompile the problematic module instead | ||
of rerunning configuration for all modules. | of rerunning configuration for all modules. | ||
==Open build shell== | |||
All the build command with 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: | |||
<syntaxhighlight lang="bash"> | |||
call "C:\Program File (x86)\Microsoft Visial Studio\2022\BuildTools\VC\Auxilary\Build\vcvarsall.bat" amd64 | |||
</syntaxhighlight> | |||
The location of the script my vary please refer to [https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022 Microsoft documentation]. | |||
==Obtain Qt6 source code== | ==Obtain Qt6 source code== | ||
Select location for the source code and create the build directory: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
mkdir qt6 | mkdir qt6 | ||
cd qt6 | cd qt6 | ||
git clone git://code.qt.io/qt/qtbase.git | git clone git://code.qt.io/qt/qtbase.git | ||
git clone git://code.qt.io/qt/qtshadertools.git | git clone git://code.qt.io/qt/qtshadertools.git | ||
Line 29: | Line 43: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{note|QtWebEngine needs initialization of submodule.}} | |||
{{note|On Windows platform you should use 'md' instead of 'mkdir' command}} | |||
==Select branches== | ==Select branches== | ||
Line 58: | Line 72: | ||
mkdir qtbase qtshadertools qtdeclarative qtwebengine | mkdir qtbase qtshadertools qtdeclarative qtwebengine | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{note|On Windows platform you should use 'md' instead of 'mkdir' command}} | |||
==Configure and build qtbase== | ==Configure and build qtbase== | ||
From out qtbase build directory we call configure from qtbase source directory to make prefix build, which | From out qtbase build directory we call configure from qtbase source directory to make prefix build, which | ||
means that we compile and than install to specific installation directory | means that we compile and than install to specific installation directory definied with 'prefix' argument. | ||
On Linux configure command line for release builds with xcb might look like: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cd build/qtbase | cd build/qtbase | ||
../../qtbase/configure -opensource -confirm-license -release -nomake tests -nomake examples -xcb -opengl desktop -qpa xcb -no-pch -linker lld -prefix /opt/qt/6.2 | ../../qtbase/configure -opensource -confirm-license -release -nomake tests -nomake examples -xcb -opengl desktop -qpa xcb -no-pch -linker lld -prefix /opt/qt/6.2 | ||
</syntaxhighlight> | |||
{{note|To speed up linking time for webengine we decided to use lld linker.}} | |||
On Windows configure command line for release build with debug info might look like: | |||
<syntaxhighlight> | |||
cd build\qtbase | |||
..\..\qtbase\configure.bat -opensource -confirm-license -release -force-debug-info -nomake tests -nomake examples -prefix C:\opt\qt\6.2 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Here we do release build with no examples and no tests. For other configure options please refer to configure quide https://doc.qt.io/qt-6/configure-options.html | Here we do release build with no examples and no tests. For other configure options please refer to configure quide https://doc.qt.io/qt-6/configure-options.html | ||
To build and install qt base you just need to call cmake: | To build and install qt base you just need to call cmake: | ||
Line 83: | Line 108: | ||
To configure and build other modules we use qt-configure-module wrapper script for the installed qtbase module. | To configure and build other modules we use qt-configure-module wrapper script for the installed qtbase module. | ||
{{note|On windows you might want call <b>C:\opt\qt\6.2\bin\qt-cofigure-module.bat</b> instead of <b>qt-cofigure-module</b>}} | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> |
Revision as of 10:00, 17 August 2023
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 and builds everything in one go. However, this small guide shows the alternative way, so called module build, which is more robust as it clones minimum subset of modules required for QtWebEngine and compiles each module separately. It is also very flexible way of building as you can try to compile newer QtWebEngine module with older qt modules. Compiling each module separately has also 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 build shell
All the build command with 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
The location of the script my vary please refer to Microsoft documentation.
Obtain Qt6 source code
Select location for the source code and create the build directory:
mkdir qt6
cd qt6
git clone git://code.qt.io/qt/qtbase.git
git clone git://code.qt.io/qt/qtshadertools.git
git clone git://code.qt.io/qt/qtdeclarative.git
git clone git://code.qt.io/qt/qtwebengine.git
cd qtwebenigne
git submodule init
git submodule update
cd ..
Note: QtWebEngine needs initialization of submodule.
Note: On Windows platform you should use 'md' instead of 'mkdir' command
Select branches
Let's assume we want to compile Qt 6.2.4 with Qt Webengine 6.4.3 Therefore, in qtbase, qtshadertools, qtdeclarative repositories we select barnches:
git checkout origin/6.2.4
Where-else in qtwebengine
cd qtwebengine
git checkout origin/6.4.3
git submodule update
cd ..
Shadow build
It is common practice to compile project is separate build directory instead of doing in-source build, therefore we create following build layout:
mkdir build
cd build
mkdir qtbase qtshadertools qtdeclarative qtwebengine
Note: On Windows platform you should use 'md' instead of 'mkdir' command
Configure and build qtbase
From out qtbase build directory we call configure from qtbase source directory to make prefix build, which means that we compile and than install to specific installation directory definied with 'prefix' argument.
On Linux configure command line for release builds with xcb might look like:
cd build/qtbase
../../qtbase/configure -opensource -confirm-license -release -nomake tests -nomake examples -xcb -opengl desktop -qpa xcb -no-pch -linker lld -prefix /opt/qt/6.2
Note: To speed up linking time for webengine we decided to use lld linker.
On Windows configure command line for release build with debug info might look like:
cd build\qtbase
..\..\qtbase\configure.bat -opensource -confirm-license -release -force-debug-info -nomake tests -nomake examples -prefix C:\opt\qt\6.2
Here we do release build with no examples and no tests. For other configure options please refer to configure quide https://doc.qt.io/qt-6/configure-options.html
To build and install qt base you just need to call cmake:
cmake --build . --parallel
cmake --install .
Configure and build other modules
To configure and build other modules we use qt-configure-module wrapper script for the installed qtbase module.
Note: On windows you might want call C:\opt\qt\6.2\bin\qt-cofigure-module.bat instead of qt-cofigure-module
cd build/qtshadertools
/opt/qt/6.2/bin/qt-cofigure-module ../../qtshadertools
cmake --build . --parallel
cmake --install .
cd ..
cd qtdeclarative
/opt/qt/6.2/bin/qt-cofigure-module ../../qtdeclarative
cmake --build . --parallel
cmake --install .
cd ..
cd qtwebengine
/opt/qt/6.2/bin/qt-cofigure-module ../../qtwebengine
cmake --build . --parallel
cmake --install .
cd ..