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-5.3.2 x64 on Mac OS X 10.10 with Xcode 6.x so that it works on 10.6+

The problem with deploying on Mac OS X 10.6 is that it does not have libc++ installed. Therefor, you have to avoid enabling C++11 in the build of Qt itself.
We will do a shadow build, the sources are in qt-5.3.2 and we’ll build in qt-5.3.2-build.

Remove non-Apple tools from your PATH (I have macports installed):
> export PATH=/usr/bin:/bin:/usr/sbin:/sbin

Configure:
> cd qt-5.3.2-build
> ../qt-5.3.2/configure -debug-and-release -prefix /usr/local/Qt-5.3.2 -nomake examples -sdk macosx10.9 -no-c++11

Note: if you remove the ‘-no-c++11’ it will link against libc++ and require 10.7+.

Build & install with documentation:
> make
> sudo make install
> make generate_docs
> make qch_docs
> sudo make install_qch_docs

Done!

Note that with such a build, you can use C++11 language constructs in your code, it’s just the Standard Library that will not be up to C++11 standard.
i.e. language construct like this will work:
for ( auto it : vec ){}
but any new classes or methods from STL will not be available (like std::thread, etc).

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!

Building Qt-4.8.6 x64 on OS X 10.10 with Xcode 6.x so that it works on OS X 10.6+

Mostly for my own benefit, but might be useful to others.

First, you will need the latest Xcode and the latest Qt 4 release source code from http://www.qt.io, at the time I wrote this, it’s Xcode 6.1.1 and Qt 4.8.6. You will also need my patch to Qt (qt-4.8.6-mac.patch, can be found here https://github.com/sandym/qt-patches).

We will do a shadow build, that is we build out of the Qt source tree.  For this, I decompress Qt in a folder named qt-4.8.6 and I create a folder named qt-4.8.6-build next to it. So I have 2 folders, qt-4.8.6 (the sources) and qt-4.8.6-build (empty, where we will build) and a file (qt-4.8.6-mac.patch). Let’s start.

From the Terminal, first apply the patch to the source tree:
> cd qt-4.8.6
> patch -p1 < ../qt-4.8.6-mac.patch

You should make sure to remove all non-Apple tools you might have installed (like Macports in my case):
> export PATH=/usr/bin:/bin:/usr/sbin:/sbin

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 ../qt-4.8.6-build
> ../qt-4.8.6/configure -debug-and-release -no-qt3support -prefix /usr/local/Qt-4.8.6 -no-multimedia -no-audio-backend -no-phonon -no-phonon-backend -no-libtiff -no-libmng -no-dbus -no-nis -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -arch x86_64

Build and install:
> make -j3
> sudo make install

Done!