Building Qt 5.6.2 on Windows 7 with Visual Studio 2010

This is an update to my previously published post Building Qt 5.2.1 on Windows 7 with Visual Studio 2010.

Not much has changed for me: I’m still running Windows 7 (Windows 10 can wait a bit longer) and Visual Studio 2010 (I’ll probably switch to version “2017” when it’s done — and if it still runs under Win7).

But what did change is that The Qt Company put out a new Long Term Support (LTS) release in the meantime: 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.

Since I’m rarely relying on brand-new features, that’s fine with me: Better tried and true then cutting my fingers on the bleeding edge of progress 😏 .

Additionally, newer releases of the Qt framework dropped support for older compilers, including Visual Studio 2010. I plan to upgrade some time in the future (see above), but at the moment that means that there isn’t much room for me to move elsewhere, anyway.

At the time of writing this, 5.6.2 was the current version… and no pre-compiled package for Visual Studio 2010 was available.

Prerequisites and recommended installation order

  1. Microsoft Visual Studio 2010
  2. Microsoft Windows SDK 7.1
  3. Microsoft Visual Studio 2010 Service Pack 1 (needed for a 64-bit build)
  4. Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
  5. Perl
  6. Python (a new requirement, compared to my last post)

Tools like Perl should be in PATH for the command prompt build environment.

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.

Getting and building Qt

  1. Again, the download of the plain source code for older/not-mainstream versions is very well hidden on the Qt site (and I’m not going to clone the repositry with git or similar, just downloading the sources, thankyouverymuch).

    Try to get it as a zip filefrom this location.

  2. 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).

  3. Build 64-bit DLLs with Visual Studio 2010 (for 32-bit files, adjust paths, names, and options accordingly):

    1. Open the Visual Studio x64 Win64 Command Prompt (2010) from the start menu and navigate to C:\devel\ext\Qt\5.6.2\

    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 To get rid of the question whether you agree to the license.
      -prefix DIRECTORY Target directory, e.g. a full path like C:\devel\ext\Qt\5.6.2_64DLL
      -release
      -opensource
      -shared Creatings DLLs 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 (the old workaround is no longer required).
      -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…).

    3. Type nmake to kick-off the building process (to clean up configure after a failed build, use nmake distclean.)

    4. Type nmake install to move the built binaries to the target directory.

That’s it!