Time again for a follow-up to my post on building Qt’s recent LTS release with Visual Studio, now that Qt 5.9 has been published as a new long-term supported (LTS) release.
And since Qt 5.9.1 does not build with Visual Studio 2010 anylonger, this was also a good reason to switch to the freshly released Visual Studio 2017 Community Edition.
What has not changed is my reliance on Windows 7 on my main box (an upgrade is maybe due this fall or winter…); but I had also the chance to run these following steps on a Windows 10 machine (with ‘Creators Update’).
By running a current compiler now, there is not necessarily a reason for this article: a pre-compiled package of Qt for Visual Studio 2017 is available AFAIK — but I somehow got accustomed to building my own little Qt, so I’ll stick with it for now. (It’s also a good reason for practice and in this case finally triggered my switch to a newer version of Visual Studio.)
Prerequisites and recommended installation order
- Microsoft Visual Studio 2017 (Community Edition)
- … install it with the C++ Desktop workload, the C++ toolset and the Windows SDK (VS2017 is brandnew to me, this might get more detailed in future updates.)
Tools like Perl should be in PATH for the command prompt build environment.
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 of 5.9.1 for Windows as a zip file.
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
configure.batto 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.):
To get rid of the question whether you agree to the license.
Target directory, e.g. a full path like C:\devel\ext\Qt\5.9.1_64DLL
Creatings DLLs instead of static libraries.
Use Microsoft Visual C++ 2017.
Use multiple processors for compiling with Microsoft Visual C++ (-MP).
For lupdate/linguist/lrelease and so on.
Because examples (esp. OpenGL ones) messed up the build.
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…
ANGLE would translate OpenGL calls into DirectX calls.
nmaketo 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.
To clean up configure (after a failed build), use
nmake installto 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.)
Film & Television (24)
How To (39)
News & Announcements (20)
On Software (8)
Plans & Projects (7)