Monthly Archives: June 2018

Building Qt apps for Windows XP in 2018

Windows XP has been discontinued and unsupported both by Microsoft and The Qt Company for a long time now. However, in 2018 its install base is still significant, at around 6% of all desktop PC machines. Chances are your customers will require that your product runs on Windows XP, too.

If you are in this predicament, you have several options:

  1. Go with MSVC 2017 and use Windows XP targetting. You’ll need to compile Qt SDK on your own, which might be an issue: Qt 4 does not officially support newer MSVC compilers and Qt 5 is dropping Windows XP support.
  2. Go with VC 2010, Windows 7.1A SDK and Qt 4.8.x which is the last pre-built SDK that supports this platform. You’ll be stuck with Qt 4, but hey, you are already stuck with Windows XP to begin with.
  3. Go with MinGW. You could even build on Linux and cross-compile to Windows.

In hindsight, probably the MinGW way would be the easiest, but when targeting Windows, I prefer the native MS compilers, so I chose to go with option #2.

Let’s go:

  • Get a Windows 7/8/10 machine, ideally separate machine or a VM, so you potentially don’t mess up your workstation.
  • Download and install Windows 7 SDK, which contains the VC 2010 compilers. If you get errors from the SDK installer, see this and this. Uninstalling VC 2010 Redistributable before installing the SDK should fix this.
  • Download and install Update for the MSVC 2010 compilers, because due to a bug in the MS SDK installer they are not installed if you are on a Windows 10 machine. This will get you the compilers in a standalone installer that should work.
  • Download and install the latest Qt 4 SDK release for VS 2010.

If everything installed properly, even with the mentioned issues, you should have a working build environment that is capable of targeting Windows XP. Now let’s build something:

%QTDIR%\bin\qtvars.bat
"C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\SetEnv.cmd" /x86 /xp /release
qmake <source_dir>/project.pro
nmake

Hopefully the build went OK and you can deploy to your Windows XP customers. In my case however, the build ended up in error – the compiler failed to find several includes: ammintrin.hinttypes.h and stdint.h. I fixed this by simply “stealing” these files from another installation of VS2012 and copied them over to the VS2010 install dir: to c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\.

Advertisements