How to target Windows XP in Microsoft Visual Studio C++ [duplicate] How to target Windows XP in Microsoft Visual Studio C++ [duplicate] windows windows

How to target Windows XP in Microsoft Visual Studio C++ [duplicate]


In order to build a Windows XP compatible EXE with VS 2015 (or VS 2012 / VS 2013) you have to use the v140_xp Platform Toolset rather than the default v140 Platform Toolset.

UPDATE: Note that VS 2017 includes support for Windows XP via v141_xp. For VS 2019, this feature is no longer being updated but you can still install the v141_xp toolset to use with the VS 2019 IDE.

See your Project Properties, the General page:

Property Page

This is because the default Platform Toolset uses the Windows 8.1 SDK (or you can opt into the Windows 10 SDK), and this only supports building applications for Windows Vista or later. When you select the v140_xp Platform Toolset, you are using a version of the Windows 7.1 SDK which was the last version to support targeting Windows XP or Windows Server 2003.

Note that Visual Studio can target Windows XP Service Pack 3 or Windows Server 2003 Service Pack 2. The C/C++ Runtime is not compatible with older versions of Windows.

If you are using DirectX in your app, this has some profound implications because a lot changed between the Windows 7.1 SDK and the Windows 8 SDK. See this post for details.

With VS 2015, you will also need to select the Windows XP support in the Custom Install options or via Programs & Features / Microsoft Visual Studio 2015 / Change... / Modify:

Modify


It sounds like the program runs fine on your development machine (Windows 8.1 + MSVS 2015), but doesn't run on an XP machine.

SOLUTION: you must include the MSVC runtime along with your .exe.

Look here: Deploying Native Desktop Applications (Visual C++)

and here: Visual C++ Redistributable for Visual Studio 2015.


Update from Chuck Walbourn -

Note that in the particular case of VS 2015 Update 3 and VS 2017, youcan use the VS 2017 or 2019 REDIST and it will work fine. See:

And to repeat - your "setup" should include a compatible MSVC runtime (aka "VCRedist").