In this post I’ll try to give a concise, but thorough guide on how to build the open source versions of Qt5 and Qt6. Before you continue reading, make sure you understand the Qt license conditions:
Please note that these instructions were written to build a minimal version of Qt. This also minimizes the amount of data to download (48M qtbase vs 629M full tar.xz archive) and the amount of files to compile. You will get the following Qt modules: Core
, Concurrent
, Gui
, Network
, OpenGL
, PrintSupport
, Sql
, Test
, Widgets
and Xml
.
If you prefer not to compile Qt by yourself, but don’t want to use the official Qt installer either, some alternatives are listed at the end of this post.
Common build requirements
For both Qt5 and Qt6 you will need to have Python and Perl installed. If you’re not sure whether one or both of them are already installed, you can open a terminal and check with python --version
and perl -v
.
If Python isn’t installed, go to python.org and install the latest version. If Perl isn’t installed, go to strawberryperl.com and install the latest version. Since I do not need Perl for my everyday work, I’m using the portable version of Strawberry Perl. To make the portable version available temporarily, execute the following command in the terminal (adjust path if necessary)
set PATH=C:\strawberry-perl\perl\bin;%PATH%
Compiling Qt5
All information given in this section is based on the following sources in the Qt docs and wiki:
- https://doc.qt.io/qt-5/windows-requirements.html
- https://doc.qt.io/qt-5/windows-building.html
- https://wiki.qt.io/Building_Qt_5_from_Git#Windows
First, lets download the latest version of Qt5 (version 5.15.17 as of writing). Go to
and navigate into the subfolder of the latest version, i.e. 5.15
/ 5.15.17
/ submodules
. Download the qtbase archive (either .zip or .tar.gz). Here’s the full link to the archive:
Extract the Qt5 source code archive, for example to C:\Qt\qt5-src
(the folder should contain a configure.bat
file).
-opengl desktop
option to always use the native OpenGL driver for rendering. Without this option, Qt will use ANGLE, which unfortunately results in additional dependencies on some GNU utilities. Those are provided only in the full Qt5 source archive, read the docs for more info.
The source directory also contains a file config_help.txt
explaining all available configuration options. For an online version, see https://github.com/qt/qtbase/blob/5.15/config_help.txt.
Open the x64 Native Tools Command Prompt from the Windows start menu and execute the following commands (adjust paths if necessary):
set PATH=C:\Qt\qt5-src\qtbase\bin;%PATH%
cd C:\Qt\qt5-src
mkdir build
cd build
..\configure -debug-and-release -nomake examples -nomake tests -schannel -opensource -confirm-license -mp -opengl desktop -prefix "C:\Qt\Qt-5.15"
nmake
nmake install
Be patient! The build step will need some time.
After executing the install step, libraries and headers will be in the corresponding subfolders of the specified install prefix, for example C:\Qt\Qt-5.15
. In the lib
folder you will also find a cmake
subfolder. When building a CMake project which depends on Qt5, all you need to do is specifying C:\Qt\Qt-5.15\lib\cmake\Qt5
as Qt5_Dir
and CMake will pick up all available modules.
Compiling Qt6
All information given in this section is based on the following Qt docs:
To download Qt6 (version 6.9.1 as of writing) go to
and navigate into the subfolder of the latest version, i.e. 6.9
/ 6.9.1
/ submodules
. Download the qtbase archive (either .zip or .tar.gz). Here’s the full link to the archive:
In case you are upgrading an Qt5 application, you might also want to download the Qt5 compatibility package (see Qt docs and blog post):
In addition to Python and Perl, you will need CMake and Ninja. If you’re not sure whether one or both of them are already installed, you can open a terminal and check with cmake --version
and ninja --version
. Make sure that both tools are available from the terminal, for example by adding them temporarily to PATH
:
set PATH=C:\path\to\cmake;C:\path\to\ninja;%PATH%
Extract the Qt6 source code archive, for example to C:\Qt\qt6-src
(the folder should contain a configure.bat
file). Open the x64 Native Tools Command Prompt from the Windows start menu and execute the following commands (adjust paths if necessary):
cd C:\Qt\qt6-src
configure -debug-and-release -nomake examples -nomake tests -no-dbus -prefix "C:\Qt\Qt-6.9"
cmake --build . --parallel
ninja install
The source directory contains a file config_help.txt
explaining all available configuration options. For an online version, see https://github.com/qt/qtbase/blob/6.9/config_help.txt.
Qt binaries
Official Qt binaries for Windows desktop are distributed under
The file listings are a bit confusing. Direct download links for versions 5.15.2
(outdated) and 6.9.1
are
-
5.15.2-qtbase-MSVC2019-Windows-10-22H2-X86_64.7z
5.15.2-qtbase-MSVC2019-Windows-10-22H2-X86_64.7z.sha1 -
6.9.1-qtbase-MSVC2022-Windows-11-23H2-X86_64.7z
6.9.1-qtbase-MSVC2022-Windows-11-23H2-X86_64.7z.sha1
Instead of using the official, but outdated 5.15.2 binaries, you can find the latest version on
There’s also an unofficial, multi-platform CLI installer for Qt available, which will help download the official binaries:
Basic usage:
# list available versions
aqt list-qt windows desktop
# list available architectures for given version
aqt list-qt windows desktop --arch 6.9.1
# list available modules for given version and architecture
aqt list-qt windows desktop --modules 6.9.1 win64_msvc2022_64
# Download only qtbase for given version and architecture (without any modules)
aqt install-qt windows desktop 6.9.1 win64_msvc2022_64 --archives qtbase
# Download qtbase for given version and architecture with qt5compat module
aqt install-qt windows desktop 6.9.1 win64_msvc2022_64 --modules qt5compat --archives qtbase
For detailed information, read the docs at
Please use the contact form for comments.