Short guides on how to build your own copy of the Qt 5 framework from source.
These were originally separate blog posts, but since they are now pretty outdated (since they are for old versions of Qt, Windows and Visual Studio), I combined them here on a single page, for archival purposes (with many dead links…), and edited them a bit.
Official page: Qt 5 for Windows - Requirements: Building from Source.
Building Qt 5.14.0 on Windows 10 with Visual Studio 2019
๐ก Originally posted 2020-01-25 ยท updated 2022-02-16
Prerequisites
- Microsoft Visual Studio 2019 (Community Edition) (install it at least with the C++ Desktop workload, the C++ toolset and the Windows SDK)
- Perl/ActivePerl (should be put in PATH for the command prompt build environment after installation)
- Python (should be put in PATH for the command prompt build environment after installation)
Download
Qt 5.14.0 Zip file~~ [DEAD LINK] (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
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).
Build
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…). -
Run Qt’s
configure.bat
from 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.
Runconfigure -h
to get the full list of options.Note: I removed now several -no-… options (e.g.
-no-opengl
,-no-openssl
etc.) 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).Argument Comment -confirm-license
Automatically acknowledge the license. -prefix <DIR>
Target directory, as a full path! -release
Release-only build (Build Qt with debugging turned off). -opensource
Build the Open Source Edition of Qt. -shared
Build shared Qt libraries (DLL) instead of static libraries. -silent
Reduce the build output so that warnings and errors can be seen more easily. -platform win32-msvc
Use Microsoft Visual C++. -mp
Use multiple processors for compilation (Microsoft Visual C++ only). -make tools
For lupdate/linguist/lrelease and so on (see also). -nomake examples
Exclude examples. -nomake tests
Exclude tests. 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 ...
-
Type
nmake
to 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…)
(Usenmake clean
ornmake distclean
to clean up the configure after a failed build.) -
Type
nmake install
to move the built binaries to the target directory.
Building Qt 5.12.3 on Windows 10 with Visual Studio 2017
๐ก Originally posted 2019-05-16
The Qt Company has released a new Long Term Support (LTS) version of the Qt framework and I think I should also update the version for my projects; thus: Time for a new post!
Prerequisites
- Microsoft Visual Studio 2017 (Community Edition) (install it at least with the C++ Desktop workload, the C++ toolset and the Windows SDK)
- Perl/ActivePerl (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)
Download
Qt LTS 5.12.3 Zip file[DEAD LINK] (ca. 800 MByte).
The way to get to the download links for the offline sources is not so obvious, so here are some directions to the main download page, for future versions:
Qt homepage โ Download โ Go Open Source โ Download Qt Installer โ Down below, near the page’s bottom: “[…] if you are looking for offline packages you can get them here.”
โ Section Source packages & Other releases: “The source code is available: For Windows users a single zip file…”.
Extract
Extract it to an appropriate place for you (e.g. I use C:\devel\ext\Qt\5.12.3\
in my environment).
If your extraction tool of choice puts it into sub-directories like qt-everywhere-opensource-src-5.12.3,
then move the content of it up to the root level and delete this now empty folder(s).
Build
The next steps describe how you build 64-bit DLLs with Visual Studio 2017; 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 2017 (you can find it in the start menu entry ‘Visual Studio 2017’) and navigate to
C:\devel\ext\Qt\5.12.3\
(or whatever your chosen location is…). -
Run Qt’s
configure.bat
from there to prepare the build.Note that the following list of options is a setup that works for me, for my current projects; you may need different features enabled/disabled, etc.
Runconfigure -h
to get the full list of options.Argument Comment -confirm-license
Automatically acknowledge the license. -prefix <DIR>
Target directory, as a full path! -release
Release-only build (Build Qt with debugging turned off). -opensource
Build the Open Source Edition of Qt. -shared
Build shared Qt libraries (DLL) instead of static libraries. -platform win32-msvc2017
Use Microsoft Visual C++ 2017. -mp
Use multiple processors for compilation (Microsoft Visual C++ only). -make tools
For lupdate/linguist/lrelease and so on (see also). -nomake examples
Exclude examples. -nomake tests
Exclude tests. -no-icu
Do not build the library for Unicode and Globalization support. This would be required for building Qt WebKit.
But Qt also supports Unicode by default and ICU seems to be on the way out for Qt’s future…-no-opengl
Do not build OpenGL. -no-angle
Do not build ANGLE (would translate OpenGL calls into DirectX calls). -no-openssl
Do not use OpenSSL support. That means, you’ll execute a long command, like:
C:\devel\ext\Qt\5.12.3\> configure.bat -confirm-license -prefix C:\devel\ext\Qt\5.12.3\_64DLL -release ...
-
Type
nmake
to kick-off the building process; this will take quite a while (on my current, not very modern setup: hours…)
(Usenmake distclean
to clean up the configure after a failed build.) -
Type
nmake install
to move the built binaries to the target directory.
Building Qt 5.9.1 on Windows 7/10 with Visual Studio 2017
๐ก Originally posted 2017-08-18 ยท updated 2022-02-16
Prerequisites
- Microsoft Visual Studio 2017 (Community Edition) (install it at least with the C++ Desktop workload, the C++ toolset and the Windows SDK)
- Perl (should be put in PATH for the command prompt build environment after installation)
- Python (should be put in PATH for the command prompt build environment after installation)
Getting and building Qt
-
The download of the plain source code for older/not-mainstream versions is well hidden on the Qt site. On the Open-Source-Download page, under section 2, there’s “Source packages & Other releases”, where you can get the source code for Windows as the
Qt 5.9.1 Zip file[DEAD LINK]. -
Extract it to an appropriate place, e.g.
C:\devel\ext\Qt\5.9.1\
. If your extraction tool of choice puts it into sub-directories like qt-everywhere-opensource-src-5.9.1 then move the content of it up to the root level and delete this now empty folder(s). -
Build 64-bit DLLs with Visual Studio 2017 (for 32-bit files, adjust paths, names, and options accordingly):
-
Open the x64 Native Tools Command Prompt for VS 2017 from the start menu (Visual Studio 2017 -> Visual Studio Tools -> VC) and navigate to
C:\devel\ext\Qt\5.9.1\
. -
Run Qt’s
configure.bat
to set up the build, for example with these parameter values (note that this is a setup that works for me, but I use Qt currently only for certain projects with specific needs; you may need different features enabled/disabled, etc.):Argument Comment -confirm-license
Automatically acknowledge the license. -prefix <DIR>
Target directory, as a full path! -release
Release-only build (Build Qt with debugging turned off). -opensource
Build the Open Source Edition of Qt. -shared
Build shared Qt libraries (DLL) instead of static libraries. -platform win32-msvc2017
Use Microsoft Visual C++ 2017. -mp
Use multiple processors for compiling with Microsoft Visual C++ (-MP). -make tools
For lupdate/linguist/lrelease and so on (see also). -nomake examples
Because examples (esp. OpenGL ones) messed up the build. -nomake tests
-no-icu
Library for Unicode and Globalization support. This would be required for building Qt WebKit.
But Qt also supports Unicode by default and ICU seems to be on the way out for Qt’s future…-no-opengl
-no-angle
ANGLE would translate OpenGL calls into DirectX calls. -no-openssl
-
Type
nmake
to kick-off the building process; this will take quite a while…
If you get at the very end get some minor errors from the tools (not able to ‘cd’ etc.), but not failure of the build itself, just ignore it.
(Usenmake distclean
to clean up the configure after a failed build.) -
Type
nmake install
to move the built binaries to the target directory.
(Again: If you get at the very end get some minor errors from the tools (not able to ‘cd’ etc.), just ignore it.)
-
Building Qt 5.6.2 on Windows 7 with Visual Studio 2010
๐ก Originally posted 2016-11-28
Qt 5.6.0 has officially seen the light of the day in March 2016, and the 5.6.x branch shall be supported for the next three years (Long Term Support [LTS] release).
By the way: Newer releases of the Qt framework dropped support for older compilers, including Visual Studio 2010.
Prerequisites and recommended installation order1
- Microsoft Visual Studio 2010
- Microsoft Windows SDK 7.1
- Microsoft Visual Studio 2010 Service Pack 1 (needed for a 64-bit build)
- Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
- Perl (should be put in PATH for the command prompt build environment after installation)
- Python (new requirement! Should be put in PATH for the command prompt build environment after installation)
Getting and building Qt
-
The download of the plain source code for older/not-mainstream versions is very well hidden on the Qt site:
Zip file[DEAD LINK]. -
Extract it to an appropriate place, e.g.
C:\devel\ext\Qt\5.6.2\
(if your extraction tool puts it into a sub-directory named qt-everywhere-opensource-src-5.6.2 then move the content one level up and delete this folder). -
Build 64-bit DLLs with Visual Studio 2010 (for 32-bit files, adjust paths, names, and options accordingly):
-
Open the Visual Studio x64 Win64 Command Prompt (2010) from the start menu and navigate to
C:\devel\ext\Qt\5.6.2\
-
Run
configure
to set up the build, for example with these parameter values (note that this is a setup that works for me, but I use Qt currently only for certain projects with specific needs; you may need different features enabled/disabled, etc.):Argument Comment -confirm-license
Automatically acknowledge the license. -prefix <DIR>
Target directory, as a full path! -release
Release-only build (Build Qt with debugging turned off). -opensource
Build the Open Source Edition of Qt. -shared
Build shared Qt libraries (DLL) instead of static libraries. -platform win32-msvc2010
Use Microsoft Visual C++ 2010. -mp
Use multiple processors for compiling with Microsoft Visual C++ (-MP). -make tools
For lupdate/linguist/lrelease and so on (see also). -nomake examples
Because examples (esp. OpenGL ones) messed up the build. -nomake tests
-no-icu
Library for Unicode and Globalization support. This would be required for building Qt WebKit.
But Qt also supports Unicode by default and ICU seems to be on the way out for Qt’s future…-no-opengl
-no-angle
ANGLE would translate OpenGL calls into DirectX calls. -no-openssl
Other changes to the configuration since my run with for 5.2.1:
-skip qtwebkit
and-skip qtwebkit-examples
are no longer necessary because “With Qt 5.6 the [QtWebKit] modules are no longer part of the release packages, but users can still build them from source.” source “New Features in Qt 5.6: Removed Modules”].The Chromium-based QtWebEngine is the (heavier) replacement for it, but isn’t built using the above configuration either (and building it might be tricky, according to some older posts…).
-
Type
nmake
to kick-off the building process (to clean up configure after a failed build, usenmake distclean
.) -
Type
nmake install
to move the built binaries to the target directory.
-
Building Qt 5.2.1 on Windows 7 with Visual Studio 2010
๐ก Originally posted 2014-04-12 ยท updated 2022-02-16
For my first steps with Qt, I wanted to use the 64-bit libraries of Qt 5.2.1 on Windows 7 with Visual Studio 2010; unfortunately the project doesn’t offer a binary package download for this combination, so I had to build the framework myself.
After some failures at this (mostly due to out of date tutorials and documentation on the web), I finally could create the libraries to my current liking…
Prerequisites and recommended installation order1
- Microsoft Visual Studio 2010
- Microsoft Windows SDK 7.1
- Microsoft Visual Studio 2010 Service Pack 1 (needed for a 64-bit build)
- Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
- Perl
Tools like Perl should be in PATH for the command prompt build environment.
Getting and building Qt
-
Hidden in the small text on the Qt Project Download Page:
The source code is also available as a single
zip[DEAD LINK] […] file for Windows users -
Extract it to an appropriate place, e.g.
C:\devel\ext\Qt\5.2.1\
(if your extraction tool puts it into a sub-directory named qt-everywhere-opensource-src-5.2.1 then move the content one level up and delete this folder). -
Build 64-bit DLLs with Visual Studio 2010:
-
Open the Visual Studio x64 Win64 Command Prompt (2010) from the start menu and navigate to
C:\devel\ext\Qt\5.2.1\
. -
Run
configure
to set up the build, for example with these parameter values:Argument Comment -confirm-license
Automatically acknowledge the license. -prefix <DIR>
Target directory, as a full path! -release
Release-only build (Build Qt with debugging turned off). -opensource
Build the Open Source Edition of Qt. -shared
Build shared Qt libraries (DLL) instead of static libraries. -platform win32-msvc2010
Use Microsoft Visual C++ 2010. -mp
Use multiple processors for compiling with Microsoft Visual C++ (-MP). -make tools
For lupdate/linguist/lrelease and so on (see also). -nomake examples
Because examples (esp. OpenGL ones) messed up the build. -nomake tests
-no-icu
Library for Unicode and Globalization support. This would be required for building Qt WebKit.
But Qt also supports Unicode by default and ICU seems to be on the way out for Qt’s future…-no-opengl
-no-angle
ANGLE would translate OpenGL calls into DirectX calls. -no-openssl
-skip qtwebkit
-skip qtwebkit-examples
-
Type
nmake
to kick-off the building process
(usenmake clean
to clean up the configure after a failed build). -
Type
nmake install
to move the built binaries to the target directory.
-
-
You might also want to read Pavel Holoborodko’s How To Compile Qt [4.7] with Visual Studio [2010] for some background information and understanding. ↩︎ ↩︎
Film & Television (54)
How To (63)
Journal (17)
Miscellaneous (4)
News & Announcements (21)
On Software (12)
Projects (26)