I'd like to make a completely static build of Qt 4.8/5.2 under VS2012 - including static runtime libraries, and targeting Windows XP systems. This is not supported out-of-the-box by Qt, since even the static build of Qt uses the dynamically linked MSVC runtime.
This is to be a canonical question that provides the knowledge necessary to successfully build Qt meeting those requirements.
Qt 5.2
Assuming that the environment was prepared for XP targeting, and relevant XP-targeting
qt5xp.patch
and the bug fixqt5fixes.patch
available - both from my other answer, we have to do the following:Create a separate
win32-msvc2012-static
andwin32-msvc2012-static-xp
qmake specs by copying them fromqtbase/mkspecs/win32-msvc2012
andqtbase/mkspecs/win32-msvc2012-xp
, respectively.Modify the qmake specs.
Teach configure and qmake makefile about the new qmake specs.
Force bootstrap of
configure.exe
by creating an empty.gitignore
file inqtbase
.If you're configuring Qt with a
-prefix
so that the installation and build directories are separate, you must apply the patch for QTBUG-32519 - at least until that bug gets fixed.The following batch file does the complete job. At the moment, webkit building is disabled for static Qt builds.
To undo the changes to the Qt source, run the following, with variables set as above:
The build is then performed by executing
Qt 4.8
Assuming that the environment was prepared for XP targeting, and relevant XP-targeting
qt4xp.patch
and the bug fixqt4fixes.patch
available - both from my other answer, the following script does the job:To undo the changes to the Qt source, run the following, with variables set as above:
The build is then performed by executing