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.
Building Qt 6 from Git: Difference between revisions
(Copy some init-repository notes from the Qt 5 wiki) |
|||
(33 intermediate revisions by 14 users not shown) | |||
Line 7: | Line 7: | ||
If you simply want to build a specific release of Qt from source to use the libraries in your own project, you can download the source code from the [http://download.qt.io/official_releases/qt/ Official Releases] page or the [http://download.qt.io/archive/qt/ Archive]. Alternatively, commercial customers can download the Source Packages via the [https://account.qt.io Qt Account] portal. | If you simply want to build a specific release of Qt from source to use the libraries in your own project, you can download the source code from the [http://download.qt.io/official_releases/qt/ Official Releases] page or the [http://download.qt.io/archive/qt/ Archive]. Alternatively, commercial customers can download the Source Packages via the [https://account.qt.io Qt Account] portal. | ||
To compile Qt Creator, see [[Building Qt Creator from Git]]. | *To compile Qt Creator, see [[Building Qt Creator from Git]]. | ||
*To compile Qt 5, see [[Building Qt 5 from Git]]. | |||
*For the ways Linux distributions package Qt 6, see [[Linux distributions that build Qt 6]]. | |||
==System Requirements== | |||
*[https://git-scm.com/ Git] ('''>= 1.6.x''') | |||
*[https://cmake.org/ CMake] ('''>= 3.16''', '''>= 3.18.4''' for Ninja Multi-Config, '''>= 3.19''' for WebEngine, '''>= 3.21.1''' for static Qt builds in Qt 6.2+, or builds for Apple platforms in Qt 6.6+) | |||
*[https://ninja-build.org/ Ninja] | |||
*C++ compiler supporting C++ 17 | |||
*Perl ('''>=5.14''', optional for Qt '''>= 6.5''') | |||
*[https://www.python.org Python] ('''>=2.6.x''') | |||
*libclang ('''>=10''', optional when QDoc should be built, prebuilt versions for each OS can be [https://download.qt.io/development_releases/prebuilt/libclang/ downloaded here] or installed through the libclang-dev package on Linux) | |||
*Windows: Visual Studio 2022, Visual Studio 2019, [https://download.qt.io/development_releases/prebuilt/mingw_64/MinGW-w64-x86_64-11.2.0-release-posix-seh-rt_v9-rev1.7z MinGW 11.2] | |||
*Linux: OpenGL developing library (libgl-dev, libegl-dev), libfontconfig1-dev (for fonts to be rendered correctly), libinput-dev (for the XCB platform plugin), and the XCB libraries mentioned in https://doc.qt.io/qt-6/linux-requirements.html | |||
Note for MSVC: A suitable CMake and Ninja version are already provided by the Visual Studio 2019/2022 and don't need to be installed separately. A Perl version which does not need a registration and also provides a zip file instead an installer is [https://strawberryperl.com/ StrawberryPerl]. | |||
== | ==System Requirements - Qt WebEngine and Qt PDF== | ||
Qt WebEngine and Qt PDF have additional build requirements | |||
* | *Python ('''>=3.6.x''') | ||
* | *Python html5lib | ||
* | *Bison, Flex | ||
*GPerf | |||
*Node.js version 8 or later (version 12 or later is recommended) | |||
*Windows: Visual Studio 2019 '''v16.11+''' (required for '''QtWebEngine''' to address an issue with defaulted noexcept operators) | |||
*Windows: Windows 10 SDK '''>= 10.0.19041.0 (version 2004)''' for '''QtWebEngine''' | |||
==Getting the source code== | ==Getting the source code== | ||
Line 26: | Line 40: | ||
First clone the top-level Qt git repository: | First clone the top-level Qt git repository: | ||
$ git clone <nowiki>git://code.qt.io/qt/qt5.git</nowiki> | $ git clone <nowiki>git://code.qt.io/qt/qt5.git qt6</nowiki> | ||
or (if you're behind a firewall and want to use the https protocol): | or (if you're behind a firewall and want to use the https protocol): | ||
$ git clone <nowiki>https://code.qt.io/qt/qt5.git</nowiki> | $ git clone <nowiki>https://code.qt.io/qt/qt5.git qt6</nowiki> | ||
''Do not worry about the name mentioning qt5.git. This is also used for Qt 6.'' | ''Do not worry about the name mentioning qt5.git. This is also used for Qt 6.'' | ||
Then check out the target branch (see [[Branch Guidelines]]). | Then check out the target branch (see [[Branch Guidelines]]). | ||
Latest changes are in <kbd>dev</kbd>, but | |||
you may check out sources of any publicly released and tagged version, | |||
or of any currently active branch. | |||
$ cd qt6 | |||
$ git switch dev | |||
In order to build a specific release of Qt, you can checkout the desired tag, for example: | |||
$ cd qt6 | |||
$ git switch v6.3.0 | |||
for the 6.3.0 release; or you could likewise checkout 6.4 for the 6.4 stabilisation branch. | |||
For commercial-only modules and commercial-only branches of public modules, see [[Getting Commercial Qt Sources]]. | |||
===Getting the submodule source code=== | ===Getting the submodule source code=== | ||
Line 45: | Line 71: | ||
Relevant options for <tt>init-repository</tt>: | Relevant options for <tt>init-repository</tt>: | ||
*<tt>--module-subset</tt> : For example, to get modules for Qt Quick development: <tt>--module-subset=qtbase,qtshadertools,qtdeclarative | *<tt>--module-subset</tt> : For example, to get modules for Qt Quick development: <tt>--module-subset=qtbase,qtshadertools,qtdeclarative</tt>. You can always add or remove individual submodules later with <tt>git submodule init/deinit</tt>. | ||
*<tt>--codereview-username <Jira/Gerrit username></tt> : If you plan to contribute to Qt, you may specify your [[Setting_up_Gerrit|codereview username]] (pay attention to capitalization!) so that the git remotes are properly set up. Note that it is recommended to adjust your ssh configuration instead. | *<tt>--codereview-username <Jira/Gerrit username></tt> : If you plan to contribute to Qt, you may specify your [[Setting_up_Gerrit|codereview username]] (pay attention to capitalization!) so that the git remotes are properly set up. Note that it is recommended to adjust your ssh configuration instead. | ||
$ cd | $ cd qt6 | ||
$ perl init-repository | $ perl init-repository | ||
Line 61: | Line 81: | ||
Qt 6 is built with CMake, and can be configured also by just running ''cmake'' with appropriate options. We provide some convenience scripts though that makes configuring Qt, and individual Qt modules easier. | Qt 6 is built with CMake, and can be configured also by just running ''cmake'' with appropriate options. We provide some convenience scripts though that makes configuring Qt, and individual Qt modules easier. | ||
A build script called <tt>configure</tt> (or <tt>configure.bat</tt> for Windows) will be in the directory that you git cloned the source code into (<tt>~/ | A build script called <tt>configure</tt> (or <tt>configure.bat</tt> for Windows) will be in the directory that you git cloned the source code into (<tt>~/qt6</tt> if you followed the directions above). You will want to call that script from a different, parallel-level directory, because you do not want to build Qt in the directory that holds the source code. Instead, you should use a "shadow build", meaning you should not build into the source directory. | ||
===On Linux:=== | |||
$ mkdir qt6-build | $ mkdir qt6-build | ||
$ cd qt6-build | $ cd qt6-build | ||
$ ../ | $ ../qt6/configure -prefix /path/to/install | ||
$ cmake --build . --parallel 4 | $ cmake --build . --parallel 4 | ||
$ cmake --install . | $ cmake --install . | ||
Line 71: | Line 93: | ||
Where 4 is number of jobs. You can try your own value or use auto value using --parallel without argument. | Where 4 is number of jobs. You can try your own value or use auto value using --parallel without argument. | ||
On Windows: | Where dot after "--build" [http://www.linfo.org/dot.html means] current folder. | ||
===On Windows:=== | |||
Make sure to open the correct command prompt (e.g. 'x64 Native Tools Command Prompt for VS 2022') which properly sets up the needed environment variables. Also make sure that Ninja can be found (by adding the path to ninja,exe to your PATH env var) | |||
> mkdir qt6-build | > mkdir qt6-build | ||
> cd qt6-build | > cd qt6-build | ||
> ..\ | > ..\qt6\configure.bat -prefix C:\path\to\install | ||
> cmake --build . | > cmake --build . | ||
> cmake --install . | > cmake --install . | ||
Line 81: | Line 107: | ||
Run <tt>configure -help</tt> to get an overview of available options. | Run <tt>configure -help</tt> to get an overview of available options. | ||
You | You may also pass CMake options directly to configure: | ||
> ../ | > ../qt6/configure -- -DQT_BUILD_TESTS=ON | ||
All options which are specified after a double-dash (--), will be passed verbatim to CMake. | |||
See [https://github.com/qt/qtbase/blob/dev/cmake/configure-cmake-mapping.md cmake/configure-cmake-mapping.md] in the sources for an overview of available options and how they map to CMake options. | |||
===Developer Builds=== | ===Developer Builds=== | ||
Line 91: | Line 120: | ||
This can take quite some time though. If you do want to be able to build the tests, but only on request, configure with CMake variable <kbd>QT_BUILD_TESTS_BY_DEFAULT=OFF</kbd>: | This can take quite some time though. If you do want to be able to build the tests, but only on request, configure with CMake variable <kbd>QT_BUILD_TESTS_BY_DEFAULT=OFF</kbd>: | ||
$ ../ | $ ../qt6/configure -developer-build -- -DQT_BUILD_TESTS_BY_DEFAULT=OFF | ||
$ cmake --build . --parallel | $ cmake --build . --parallel | ||
Line 110: | Line 139: | ||
(for the same example); the parameter to <kbd>-R</kbd> is a regular expression, matching test names. | (for the same example); the parameter to <kbd>-R</kbd> is a regular expression, matching test names. | ||
This includes the test output; if you omit <kbd>-V</kbd> that's skipped and you just get a single-line summary of the test result. | This includes the test output; if you omit <kbd>-V</kbd> that's skipped and you just get a single-line summary of the test result. | ||
If you want to run only a particular test function, you pass it using the TESTARGS environment variable. For example: | |||
$ TESTARGS=emptyCtor ctest -V -R qlocale | |||
And if you want to run a specific test function with a specific data-tag, you provide it after a colon: | |||
$ TESTARGS=emptyCtor:en_GB ctest -V -R qlocale |
Latest revision as of 13:39, 26 June 2023
En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh
This article provides hints for checking out and building the Qt 6 repositories. This is primarily for developers who want to contribute to the Qt library itself, or who want to try the latest unreleased code.
If you simply want to build a specific release of Qt from source to use the libraries in your own project, you can download the source code from the Official Releases page or the Archive. Alternatively, commercial customers can download the Source Packages via the Qt Account portal.
- To compile Qt Creator, see Building Qt Creator from Git.
- To compile Qt 5, see Building Qt 5 from Git.
- For the ways Linux distributions package Qt 6, see Linux distributions that build Qt 6.
System Requirements
- Git (>= 1.6.x)
- CMake (>= 3.16, >= 3.18.4 for Ninja Multi-Config, >= 3.19 for WebEngine, >= 3.21.1 for static Qt builds in Qt 6.2+, or builds for Apple platforms in Qt 6.6+)
- Ninja
- C++ compiler supporting C++ 17
- Perl (>=5.14, optional for Qt >= 6.5)
- Python (>=2.6.x)
- libclang (>=10, optional when QDoc should be built, prebuilt versions for each OS can be downloaded here or installed through the libclang-dev package on Linux)
- Windows: Visual Studio 2022, Visual Studio 2019, MinGW 11.2
- Linux: OpenGL developing library (libgl-dev, libegl-dev), libfontconfig1-dev (for fonts to be rendered correctly), libinput-dev (for the XCB platform plugin), and the XCB libraries mentioned in https://doc.qt.io/qt-6/linux-requirements.html
Note for MSVC: A suitable CMake and Ninja version are already provided by the Visual Studio 2019/2022 and don't need to be installed separately. A Perl version which does not need a registration and also provides a zip file instead an installer is StrawberryPerl.
System Requirements - Qt WebEngine and Qt PDF
Qt WebEngine and Qt PDF have additional build requirements
- Python (>=3.6.x)
- Python html5lib
- Bison, Flex
- GPerf
- Node.js version 8 or later (version 12 or later is recommended)
- Windows: Visual Studio 2019 v16.11+ (required for QtWebEngine to address an issue with defaulted noexcept operators)
- Windows: Windows 10 SDK >= 10.0.19041.0 (version 2004) for QtWebEngine
Getting the source code
First clone the top-level Qt git repository:
$ git clone git://code.qt.io/qt/qt5.git qt6
or (if you're behind a firewall and want to use the https protocol):
$ git clone https://code.qt.io/qt/qt5.git qt6
Do not worry about the name mentioning qt5.git. This is also used for Qt 6.
Then check out the target branch (see Branch Guidelines). Latest changes are in dev, but you may check out sources of any publicly released and tagged version, or of any currently active branch.
$ cd qt6 $ git switch dev
In order to build a specific release of Qt, you can checkout the desired tag, for example:
$ cd qt6 $ git switch v6.3.0
for the 6.3.0 release; or you could likewise checkout 6.4 for the 6.4 stabilisation branch.
For commercial-only modules and commercial-only branches of public modules, see Getting Commercial Qt Sources.
Getting the submodule source code
As described in the README.git, initialize the repository using the init-repository script, which clones the various sub-modules of Qt 6.
Relevant options for init-repository:
- --module-subset : For example, to get modules for Qt Quick development: --module-subset=qtbase,qtshadertools,qtdeclarative. You can always add or remove individual submodules later with git submodule init/deinit.
- --codereview-username <Jira/Gerrit username> : If you plan to contribute to Qt, you may specify your codereview username (pay attention to capitalization!) so that the git remotes are properly set up. Note that it is recommended to adjust your ssh configuration instead.
$ cd qt6 $ perl init-repository
Configuring and Building
Qt 6 is built with CMake, and can be configured also by just running cmake with appropriate options. We provide some convenience scripts though that makes configuring Qt, and individual Qt modules easier.
A build script called configure (or configure.bat for Windows) will be in the directory that you git cloned the source code into (~/qt6 if you followed the directions above). You will want to call that script from a different, parallel-level directory, because you do not want to build Qt in the directory that holds the source code. Instead, you should use a "shadow build", meaning you should not build into the source directory.
On Linux:
$ mkdir qt6-build $ cd qt6-build $ ../qt6/configure -prefix /path/to/install $ cmake --build . --parallel 4 $ cmake --install .
Where 4 is number of jobs. You can try your own value or use auto value using --parallel without argument.
Where dot after "--build" means current folder.
On Windows:
Make sure to open the correct command prompt (e.g. 'x64 Native Tools Command Prompt for VS 2022') which properly sets up the needed environment variables. Also make sure that Ninja can be found (by adding the path to ninja,exe to your PATH env var)
> mkdir qt6-build > cd qt6-build > ..\qt6\configure.bat -prefix C:\path\to\install > cmake --build . > cmake --install .
Run configure -help to get an overview of available options.
You may also pass CMake options directly to configure:
> ../qt6/configure -- -DQT_BUILD_TESTS=ON
All options which are specified after a double-dash (--), will be passed verbatim to CMake.
See cmake/configure-cmake-mapping.md in the sources for an overview of available options and how they map to CMake options.
Developer Builds
The configure option -developer-build sets the install prefix to the build directory, so that no install step is necessary. It also changes defaults so that all tests (including tests using private API that is otherwise not exported) can run.
This can take quite some time though. If you do want to be able to build the tests, but only on request, configure with CMake variable QT_BUILD_TESTS_BY_DEFAULT=OFF:
$ ../qt6/configure -developer-build -- -DQT_BUILD_TESTS_BY_DEFAULT=OFF $ cmake --build . --parallel
Later on you can then build single tests, for instance :
$ cmake --build . --target tst_qstyle
Use ninja -t targets to see all the targets that are provided in the build.
See cmake/README.md in the sources for details on how to configure and build Qt 6 with CMake.
Running Tests
Once you've built (as long as you you did build with tests enabled), you can run the tests either directly using ninja tst_qlocale_check (for example, to run tests/auto/corelib/text/qlocale/tst_qlocale) or via ctest (see its man page for further options) like
$ ctest -V -R qlocale
(for the same example); the parameter to -R is a regular expression, matching test names. This includes the test output; if you omit -V that's skipped and you just get a single-line summary of the test result.
If you want to run only a particular test function, you pass it using the TESTARGS environment variable. For example:
$ TESTARGS=emptyCtor ctest -V -R qlocale
And if you want to run a specific test function with a specific data-tag, you provide it after a colon:
$ TESTARGS=emptyCtor:en_GB ctest -V -R qlocale