Building Qt 5.2.1 on Windows 7 with Visual Studio 2010

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…

  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

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

You might also want to read http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/.

Getting and building Qt

  1. There is, hidden in the small text, a link to the source code files on the Qt Project Download Page:

    The source code is also available as a single zip […] file for Windows users

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

  3. Build 64-bit DLLs with Visual Studio 2010:

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

    2. Run configure to set up the build, for example with these parameter values:

      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.2.1_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 Seems to be necessary.
      -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
    3. Type nmake to kick-off the building process (to clean up configure after a failed build, use nmake clean.)

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

That’s it!