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

From Qt Wiki
Jump to navigation Jump to search
mNo edit summary
m (Fixed branch name)
Line 11: Line 11:
To compile Qt 5, see [[Building Qt 5 from Git]]
To compile Qt 5, see [[Building Qt 5 from Git]]


== System Requirements ==
==System Requirements==


=== All desktop platforms ===
===All desktop platforms===


* Git ('''>= 1.6.x''')
*Git ('''>= 1.6.x''')
* CMake ('''>= 3.18.4''')
*CMake ('''>= 3.18.4''')
* Ninja
*Ninja
* Perl ('''>=5.14''')
*Perl ('''>=5.14''')
* Python ('''>=2.6.x''')
*Python ('''>=2.6.x''')
* A working C++ compiler, supporting at least C++ 17
*A working C++ compiler, supporting at least C++ 17


==Getting the source code==
==Getting the source code==
Line 34: Line 34:
''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]]). Currently, the only branch that exists for Qt 6 is dev, but in the future this will change, allowing to e.g. check out sources from 6.1
Then check out the target branch (see [[Branch Guidelines]]). Currently, the only branch that exists for Qt 6 is dev, but in the future this will change, allowing to e.g. check out sources from 6.0


  $ cd qt5
  $ cd qt5
  $ git checkout 6.1
  $ git checkout 6.0


===Getting the submodule source code===
===Getting the submodule source code===
Line 52: Line 52:
  $ perl init-repository
  $ perl init-repository


== Configuring and Building ==
==Configuring and Building==


Qt 6 is built with CMake, and can be configured also by just running ''cmake'' with appropriate otpions. 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 otpions. We provide some convenience scripts though that makes configuring Qt, and individual Qt modules easier.
Line 78: Line 78:
   > ../qt5/configure -- -D QT_NO_BUILD_TESTS=ON
   > ../qt5/configure -- -D QT_NO_BUILD_TESTS=ON


=== Developer Builds ===
===Developer Builds===


The configure option <kbd>-developer-build</kbd> 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.
The configure option <kbd>-developer-build</kbd> 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.
Line 95: Line 95:
See [https://github.com/qt/qtbase/blob/dev/cmake/README.md <kbd>cmake/README.md</kbd>] in the sources for details on how to configure and build Qt 6 with CMake.
See [https://github.com/qt/qtbase/blob/dev/cmake/README.md <kbd>cmake/README.md</kbd>] in the sources for details on how to configure and build Qt 6 with CMake.


=== Running Tests ===
===Running Tests===


Once you've built (as long as you you did build with tests enabled), you can run the tests either directly using <kbd>ninja tst_qlocale_check</kbd> (for example, to run <kbd>tests/auto/corelib/text/qlocale/tst_qlocale</kbd>) or via <kbd>ctest</kbd> (see its <kbd>man</kbd> page for further options) like
Once you've built (as long as you you did build with tests enabled), you can run the tests either directly using <kbd>ninja tst_qlocale_check</kbd> (for example, to run <kbd>tests/auto/corelib/text/qlocale/tst_qlocale</kbd>) or via <kbd>ctest</kbd> (see its <kbd>man</kbd> page for further options) like

Revision as of 09:26, 8 January 2021

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

System Requirements

All desktop platforms

  • Git (>= 1.6.x)
  • CMake (>= 3.18.4)
  • Ninja
  • Perl (>=5.14)
  • Python (>=2.6.x)
  • A working C++ compiler, supporting at least C++ 17

Getting the source code

First clone the top-level Qt git repository:

$ git clone git://code.qt.io/qt/qt5.git

or (if you're behind a firewall and want to use the https protocol):

$ git clone https://code.qt.io/qt/qt5.git

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). Currently, the only branch that exists for Qt 6 is dev, but in the future this will change, allowing to e.g. check out sources from 6.0

$ cd qt5
$ git checkout 6.0

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.

$ cd qt5
$ perl init-repository

In order to build a specific release of Qt, you can checkout the desired tag:

$ cd qt5
$ git checkout v6.0.0-beta4
$ perl init-repository

Configuring and Building

Qt 6 is built with CMake, and can be configured also by just running cmake with appropriate otpions. 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 (~/qt5 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.

$ mkdir qt6-build
$ cd qt6-build
$ ../qt5/configure -prefix /path/to/install
$ cmake --build .
$ cmake --install .

On Windows:

> mkdir qt6-build
> cd qt6-build
> ..\qt5\configure.bat -prefix C:\path\to\install
> cmake --build .
> cmake --install .

Run configure -help to get an overview of available options.

You can also pass CMake options directly to configure:

 > ../qt5/configure -- -D QT_NO_BUILD_TESTS=ON

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:

 $ ../qt5/configure -developer-build -- -D QT_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.