Time for another short guidance on how to build your own copy of the Qt framework from source.
I’ve upgraded to Visual Studio Community Edition 2019 (Version 16.3.10) in the meantime and will now also use the current Qt 5.14.0 release instead of the 5.12.x LTS line.
As mentioned before, building Qt from source by yourself may not be neccessary when you run up-to-date versions of the OS and IDE: Just install it via the online installer from the Qt site. I do this mostly out of habit and to keep in training 😉
Anyways, if you’re still with me, I guess you also know what/why you want it; so, on with the show.
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.
Official page: Qt 5 for Windows - Requirements: Building from Source.
The shortcut to version Qt 5.14.0 is http://download.qt.io/official_releases/qt/5.14/5.14.0/single/qt-everywhere-src-5.14.0.zip (ca. 800 MByte).
The way to get to the download links for the offline sources from the homepage is well hidden, and the ways to get there change with every redesign every couple of months… But the final URL still works: https://www.qt.io/offline-installers/. And there: Source packages & Other releases → “The source code is available: For Windows users as a single zip file”.
Extract it to an appropriate place for you (e.g. I use
C:\devel\ext\Qt\5.14.0\ in my environment).
If your extraction tool of choice puts it into sub-directories like qt-everywhere-opensource-src-5.14.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:\devel\ext\Qt\5.14.0\(or whatever your chosen location is…).
configure.batfrom there to prepare the build.
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.
Note: I removed now several -no-… options (e.g.
-no-openssletc.) that I used before here, because on the first attempt to build, the run stopped with a fatal link error after some hours (*groan*). Might have been a coincidence, but when doing it again, without these exclusions, it completed successfully (but also took a lot longer to build than before).
Automatically acknowledge the license.
The deployment directory, as seen on the target device.
<DIR> is a full path like C:\devel\ext\Qt\5.14.0\_64DLL
Release-only build (Build Qt with debugging turned off).
Build the Open-Source Edition of Qt.
Reduce the build output so that warnings and errors can be seen more easily.
Build shared Qt libraries (creating DLLs).
Use Microsoft Visual C++.
Use multiple processors for compilation (Microsoft Visual C++ only).
For lupdate/linguist/lrelease and so on.
That means, you’ll execute a long command, like:
C:\devel\ext\Qt\5.14.0\> configure.bat -confirm-license -prefix C:\devel\ext\Qt\5.14.0\_64DLL -release ...
nmaketo kick-off the building process; this will take quite a while (on my current, not very modern setup (Intel Core i5-760, 8 GB): Four to five hours…)
To clean up (e.g. after a failed build, before trying again), do
nmake installto move the built binaries to the target directory.
Film & Television (29)
How To (55)
News & Announcements (21)
On Software (8)