Time for another short guidance on how to build your own copy of the Qt framework from source.
Qt 6.1.0 was just released, and I thought maybe I should keep in touch with the latest generation, even though I don’t urgently need it right now. On the other hand, I do plan to invest some time into QML/Quick, and for that, I might as well start with the latest version.
From what I picked up over the last months, Qt seem to again as tighten the screws a bit more, regarding licenses and non-commercial support, so the advice from my previous posts, to just get the pre-built binaries via online installer (if you’re not interested in building the framework from soure), maybe doesn’t apply anyomre (don’t know really, don’t care that much). For now; just be aware that The Qt Company is an commercial entity, and just like Microsoft, Google or Apple, they want to make money in the end…
Prerequisites and recommended installation order
- Microsoft Visual Studio 2019 (Community Edition) — install it at least with the C++ Desktop workload, the C++ toolset and the Windows SDK.
- Perl/ActivePerl — it should be put in PATH for the command prompt build environment after installation.
- Python — it should be put in PATH for the command prompt build environment after installation.
Note that Qt 6 requires a Python 3.x version!
- CMake — The framework has switched to CMake for building Qt’s 6th generation, and it requires at least version 3.16 of CMake.
Official page: Qt (6) for Windows - Building from Source.
As usual, I’ll point to the zipped version of the source package; you could also clone it from a Git repository, but I’ll ignore that for now.
The direct way to the source code of version of Qt 6.1.0 is https://download.qt.io/official_releases/qt/6.1/6.1.0/single/qt-everywhere-src-6.1.0.zip,
which comes at ca. 377 MB – much lighter than last time’s 800 MByte, but as I understand, Qt 6.1 is also still missing a lot of features and modules…
(There is also a prettier website, but the download link points to the same location as above.)
Extract it to an appropriate place for you (e.g. I use
If your extraction tool of choice puts it into sub-directories like qt-everywhere-src-6.1.0, then move the content of it up to the root level and delete this now empty folder(s).
The next steps describe how you build 64-bit DLLs with Visual Studio 2019; for 32-bit files, or static libraries, or…, adjust the paths/names/options accordingly to your needs!
Open the x64 Native Tools Command Prompt for VS 2019 (you can find it in the start menu entry ‘Visual Studio 2019’) and navigate to
C:\temp\Qt-6.1.0\(or whatever your chosen location is…).
configure.batfrom there to prepare the build – but first, make some choices:
The following list of options is a setup that works for me, for my current projects; you may need different features enabled/disabled, etc.
configure -hto get the full list of options.
The installation destination directory.
<DIR> should be a full path like “C:\devel\shared\Qt-6.1.0-x64”
Release-only build (Build Qt with debugging turned off).
Build shared libraries (i.e. DLLs).
Build also tools like lupdate/linguist/lrelease and so on.
That means, you’ll execute a long command, like:
C:\temp\Qt-6.1.0\> configure.bat -prefix C:\devel\shared\Qt-6.1.0-x64 -release -shared ...
By the way: The first attempt stopped immediately for me with an error:
The message indicated that it had issues finding Ninja, and previous values in CMake’s cache wouldn’t match with the just now created configuration.
Well, I didn’t have/use Ninja, nor did I ever try to do a build of Qt 6 with CMake before this one.
Luckily, the tip in that message also helped: After deleting the file
C:\temp\Qt-6.1.0\CMakeCache.txtand trying again, it worked.
(This file shouldn’t have been there in the zip file for deployment…)
cmake --build . --parallelto kick-off the building process.
Mind the dot after “–build”! That means that the current directory [meaning
C:\temp\Qt-6.1.0\] will be also the build directory.
This may take quite a while, depending on your equipment (in my case a few hours).
To clean up (e.g. after a failed build, before trying again), delete the file
CMakeCache.txt(as already mentioned above) and configure again/new; then build this again.
cmake --install .
Again: Mind the trailing dot! This line translates to: “Install the sources from the current directory [meaning
C:\temp\Qt-6.1.0\] to the destination directory that was specified during the configuration step with the
That’s all, folks!
Film & Television (29)
How To (55)
News & Announcements (21)
On Software (8)