QtWebEngine/Qt6Build: Difference between revisions
m (add hits for lang) |
Ali.demiralp (talk | contribs) m (Correct qt-cofigure-module.) |
||
(11 intermediate revisions by one other user not shown) | |||
Line 12: | Line 12: | ||
of rerunning configuration for all modules. | of rerunning configuration for all modules. | ||
==Obtain Qt6 source code== | ==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: | |||
<syntaxhighlight lang="bash"> | |||
call "C:\Program File (x86)\Microsoft Visial Studio\2022\BuildTools\VC\Auxilary\Build\vcvarsall.bat" amd64 | |||
</syntaxhighlight> | |||
{{note| The location of the script may vary please refer to the [https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell Microsoft documentation.]}} | |||
==Obtain the Qt6 source code== | |||
Select the location for the source code and create the build directory: | |||
{{note|On Windows platform you should use 'md' instead of 'mkdir' command.}} | |||
<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 45: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{note|QtWebEngine needs initialization of the submodule.}} | |||
==Select branches== | ==Select branches== | ||
Let's assume we want to compile Qt 6.2.4 with Qt | 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 | Therefore, in qtbase, qtshadertools, qtdeclarative repositories we select branches: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 42: | Line 58: | ||
Where-else in qtwebengine | Where-else in qtwebengine | ||
<syntaxhighlight> | <syntaxhighlight lang="bash"> | ||
cd qtwebengine | cd qtwebengine | ||
git checkout origin/6.4.3 | git checkout origin/6.4.3 | ||
Line 51: | Line 67: | ||
==Shadow build== | ==Shadow build== | ||
It is common practice to compile project | It is a common practice to compile the project in separate build directory instead of doing in-source build, therefore we create the following build layout: | ||
{{note|On Windows platform you should use 'md' instead of 'mkdir' command}} | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 61: | Line 79: | ||
==Configure and build qtbase== | ==Configure and build qtbase== | ||
From | From our qtbase 'build' directory we call the configure from qtbase 'source' directory to make prefix build, which means that we will compile and than install to the specific installation directory defined with 'prefix' argument. | ||
means that we compile and than install to specific installation directory | |||
On '''Linux''' the configure command line for the release builds with xcb might look like: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cd build/qtbase | cd build/qtbase | ||
Line 69: | Line 88: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{note|To speed up linking time for WebEngine we decided to use lld linker.}} | |||
On '''Windows''' the configure command line for the 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> | |||
On '''Mac''' the configure command line for the release framework builds might look like: | |||
<syntaxhighlight lang="bash"> | |||
cd build/qtbase | |||
../../qtbase/configure -developer-build -nomake examples -release -force-debug-info -separate-debug-info -framework -prefix /opt/qt/6.2 | |||
</syntaxhighlight> | |||
or '''Mac universal''' build : | |||
<syntaxhighlight lang="bash"> | |||
cd build/qtbase | |||
../../qtbase/configure -nomake examples -release -force-debug-info -separate-debug-info -framework -prefix /opt/qt/6.2 -- -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" | |||
</syntaxhighlight> | |||
{{note| For other configure options please refer to the configure guide 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 82: | Line 122: | ||
==Configure and build other modules== | ==Configure and build other modules== | ||
To configure and build other modules we use qt-configure-module wrapper script | To configure and build other modules we use the '''qt-configure-module wrapper''' script from the installed qtbase module. | ||
{{note|On Windows you might want to call 'C:\opt\qt\6.2\bin\qt-cofigure-module.bat' instead of 'qt-cofigure-module'}} | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cd build/qtshadertools | cd build/qtshadertools | ||
/opt/qt/6.2/bin/qt- | /opt/qt/6.2/bin/qt-configure-module ../../qtshadertools | ||
cmake --build . --parallel | cmake --build . --parallel | ||
cmake --install . | cmake --install . | ||
Line 92: | Line 134: | ||
cd qtdeclarative | cd qtdeclarative | ||
/opt/qt/6.2/bin/qt- | /opt/qt/6.2/bin/qt-configure-module ../../qtdeclarative | ||
cmake --build . --parallel | cmake --build . --parallel | ||
cmake --install . | cmake --install . | ||
Line 98: | Line 140: | ||
cd qtwebengine | cd qtwebengine | ||
/opt/qt/6.2/bin/qt- | /opt/qt/6.2/bin/qt-configure-module ../../qtwebengine | ||
cmake --build . --parallel | cmake --build . --parallel | ||
cmake --install . | cmake --install . | ||
cd .. | cd .. | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 05:32, 22 August 2024
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 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 create the build directory:
Note: On Windows platform you should use 'md' instead of 'mkdir' command.
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 the submodule.
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 branches:
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 a common practice to compile the project in separate build directory instead of doing in-source build, therefore we create the following build layout:
Note: On Windows platform you should use 'md' instead of 'mkdir' command
mkdir build
cd build
mkdir qtbase qtshadertools qtdeclarative qtwebengine
Configure and build qtbase
From our qtbase 'build' directory we call the configure from qtbase '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 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 the configure command line for the 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
On Mac the configure command line for the release framework builds might look like:
cd build/qtbase
../../qtbase/configure -developer-build -nomake examples -release -force-debug-info -separate-debug-info -framework -prefix /opt/qt/6.2
or Mac universal build :
cd build/qtbase
../../qtbase/configure -nomake examples -release -force-debug-info -separate-debug-info -framework -prefix /opt/qt/6.2 -- -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 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 the qt-configure-module wrapper script from the installed qtbase module.
Note: On Windows you might want to 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-configure-module ../../qtshadertools
cmake --build . --parallel
cmake --install .
cd ..
cd qtdeclarative
/opt/qt/6.2/bin/qt-configure-module ../../qtdeclarative
cmake --build . --parallel
cmake --install .
cd ..
cd qtwebengine
/opt/qt/6.2/bin/qt-configure-module ../../qtwebengine
cmake --build . --parallel
cmake --install .
cd ..