Building Qt-5.3.2 on Windows with VS2013 so that it works on WinXP+

Since VS requires all C++ libraries to be compiled with the same version, this is a complicated one. To get everything out of Qt, we need to compile openssl and icu ourselves, all with the WinXP SDK. Let’s start.

For this, I have a folder C:\Qt where all I need is installed (python, perl, icu, ruby and jom). I uncompress Qt as C:\Qt\qt-5.3.2-src, I will build from C:\Qt\qt-5.3.2-build and install in C:\Qt\qt-5.3.2. Adjust all paths to your convenience, if you want both a 32 bits and 64 bits builds, you’ll need a different build and install folder (like C:\Qt\qt-5.3.2-buildx64 and C:\Qt\qt-5.3.2-x64).

First, open the VS2013 Command Promt, 32 or 64 bits depending on which you want to build.
Set SDK for WinXP (Note: there is a Bin64 and Lib64 for 64 bits builds, shown here are the paths for a 32 bits build).

> set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
> set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib;%LIB%
> set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
> set CL=/D_USING_V110_SDK71_

Then, you need icu and you need cygwin to build icu. So from the VS2013 cmd-line, add cygwin and compile icu:

> set PATH=%PATH%;C:\cygwin64\bin;
> cd icu-src
> bash ./runConfigureICU Cygwin/MSVC --prefix=C:/Qt/icu
> make
> make install

Note: I’m installing icu in C:/Qt/icu, if you do both 32 and 64 bits build you’ll need to install in 2 different folders (like icu32 and icu64).

Now, remove cygwin from path:

> set PATH=%PATH:C:\cygwin64\bin;=%

Need perl, python and ruby, just install them. Make sure they’re in your PATH.

> set PATH=C:\Qt\Perl64\bin;%PATH%
> set PATH=C:\Qt\Python27;%PATH%
> set PATH=C:\Qt\Ruby193\bin;%PATH%

Need openssl, to compile it:

> cd openssl-src-folder
> perl Configure VC-WIN32 no-asm --prefix=C:\Qt\openssl
> ms\do_ms
> nmake -f ms\ntdll.mak
> nmake -f ms\ntdll.mak install
> set INCLUDE=C:\Qt\openssl\include;%INCLUDE%

Note: I install openssl in C:\Qt\openssl, like for icu, take care of not mixing 32 and 64 bits builds.

Need icu’s include, bin and lib (or bin64, lib64 if a 64 bit build).

> set PATH=C:\Qt\icu\bin;%PATH%
> set PATH=C:\Qt\icu\lib;%PATH%
> set INCLUDE=C:\Qt\icu\include;%INCLUDE%
> set LIB=C:\Qt\icu\lib;%LIB%

Add some qt tools:

> set PATH=C:\Qt\qt-5.3.2-src\gnuwin32\bin;%PATH%

Configure and compile:

> cd C:\Qt\qt-5.3.2-build
> ..\qt-5.3.2-src\configure.bat -icu -debug-and-release -nomake examples -prefix c:\Qt\qt-5.3.2 -platform win32-msvc2013 -force-debug-info -target xp
> jom
> jom install
> jom generate_docs
> jom qch_docs
> jom install_qch_docs

Note: -target xp will make an XP compatible build, -force-debug-info will give us .pdb files even for the release dlls.

Done!

The resulting Qt 5.3.2 can be deployed on Windows XP or better.

Building Qt-4.8.6 x64 on Windows with VS2013 so that it works on Win7+

Easy one. I don’t need WinXP support for 64 bits, so it’s straight forward. You’ll need VS2013 and perl install (I use ActivePerl 64 bits). We’ll do a shadow build, for this I have Qt 4.8.6 sources in C:\Qt\qt-4.8.6-src, I’ll build in C:\Qt\qt-4.8.6-build and install C:\Qt\qt-4.8.6-x64.

Start the VS2013 x64 Command Prompt.

Remove cygwin from PATH:
> set PATH=%PATH:C:\cygwin\bin;=%

We need perl for shadow build:
> set PATH=C:\Qt\Perl64\bin;%PATH%

Configure, build and install:

Building Qt-4.8.6 x32 on Windows with VS2013 so that it works on WinXP+

You will need VS2013 (express works fine) and the Windows SDK v7.1A. You also need perl, I use ActivePerl 64 bits and my qt-4.8.6-win.patch (can be found here https://github.com/sandym/qt-patches). We’ll do a shadow build, for this I have Qt 4.8.6 sources in C:\Qt\qt-4.8.6, I’ll build in C:\Qt\qt-4.8.6-build and install C:\Qt\qt-4.8.6-x32.

First patch the source code, I do that from a cygwin shell:

> cd /cygdrive/c/Qt/qt-4.8.6
> patch -p1 --binary < ../qt-4.8.6-win.patch

Start the VS2013 x86 Native Tools Command Prompt.
Remove cygwin from PATH.

> set PATH=%PATH:C:\cygwin\bin;=%

Set SDK for WinXP.

> set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
> set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib;%LIB%
> set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
> set CL=/D_USING_V110_SDK71_

We need perl for shadow build:

> set PATH=C:\Qt\Perl64\bin;%PATH%

Configure, note that this is the configuration I use and know to work, you might have some luck with something different, but some do fail. You’re on your own if you do it differently.
> cd C:\Qt\qt-4.8.6-build
> ..\qt-4.8.6\configure.exe -prefix C:\Qt\qt-4.8.6-x32 —debug-and-release -no-qt3support -no-multimedia -no-audio-backend -no-phonon -no-phonon-backend -no-libtiff -no-libmng -no-dbus -no-nis -webkit -platform win32-msvc2013

Build and install:
> jom.exe
> jom.exe install

Done!