How to Target Windows Xp in Microsoft Visual Studio C++

What version of Visual Studio to target windows XP builds?

Its more of .Net framework and not IDE specific.

.Net 4.5 framework cannot be installed on XP machines. So if you are talking about development machines, its true you can't go with VS 2012/2013 since 4.5 in installed by default with them.

But if you are talking about customer machines here, you can use Windows 7/8 for development with 2012/2013 IDE but project should target .Net 4.0 framework or below.

How to compile code for Windows XP in Visual Studio 2017

What you have encountered here are issues in the header files for the XP-Compatible SDK. The problem is actually quite arcane but, fortunately, relatively easy to deal with: you simply need to 'relax' the strictness of conformity checks the compiler uses...

To do this, right-click on your project in the Solution Explorer and select "Properties." On the invoked property-page, select the "C/C++" tab, and then the "Language" sub-tab. In the page then displayed, make sure you select "Conformance Mode" to "No". That should fix the issues.

Feel free to ask for further clarification and/or explanation.

What is the latest C++ standard to target Windows XP with Visual Studio?

The latest toolset that has Windows XP support is v141_xp, that is the XP toolset from Visual Studio 2017. It has full C++14 support, and partial C++17 support.
It comes with Visual Studio 2019, too:

VS 2019 installer with selected XP toolset

Unfortunately, it does not have full C++17 and C++20 support.

The latest update of VS2019 has almost complete C++20 support in v142 toolset, and there is an update expected to make it complete, but it is without XP support.

VS2022 drops Vista and support some C++23 in its v143 toolset. It still ships with v141_xp toolset as optional [deprecated] component.

The v141_xp toolset still has the support of C++14, and partial C++17. It mostly corresponds to the Conformance table where they mention VS 2017. (Say, you will have std::any or terse static_assert, but won't be able to use shared_mutex, as it relies on Vista SRWLOCK)

See also: How to install build tools for v141_xp for VC 2017?

Targetting Windows xp from visual studio 2015 enterprise update 1

Configuring C++ 11 Programs for Windows XP

The Windows XP platform toolset that's included in Visual Studio is a version of the Windows 7 SDK that was included in Visual Studio 2010, but it uses the current C++ compiler. It also configures project properties to appropriate default values—for example, the specification of a compatible linker for down-level targeting. Only Windows desktop apps that are created by using the Windows XP platform toolset run on Windows XP and Windows Server 2003, but those apps can also run on more recent operating systems—for example, Windows Vista, Windows 7, Windows Server 2008, Windows 8, or Windows Server 2012.

To target Windows XP

  • In Solution Explorer, open the shortcut menu for your project, and then choose Properties.
  • In the Property Pages dialog box for the project, under Configuration Properties, General, set the Platform Toolset property to the desired Windows XP toolset. For example, choose Visual Studio 2012 – Windows XP (v110_xp) to create code that is binary compatible with the Microsoft Visual C++ 2012 Redistributable libraries.

How to properly set target OS version when building a library on Windows using Visual C++ compiler

Your answers to your own questions are for the most part correct. Some clarifications and corrections:

The subsystem version is orthogonal to the target architecture. What the /subsystem documentation is saying is that the minimum subsystem version for x86 is 5.01 and the minimum subsystem version for x64 is 5.02. For console and Windows apps, the subsystem version is the same as the internal operating system version number. 5.01 is x86 Windows XP; 5.02 is x64 Windows XP. There are two different version numbers for Windows XP because the x64 Windows XP was released later than the x86 Windows XP. Newer OSes have the same version number for all architectures (e.g., Windows Vista is version 6.0 for both x86 and x64).

Note that by setting the subsystem version, you can restrict the set of operating systems on which your program will run. E.g., if you set the subsystem version to 6.2, your program will only run on Windows 8 and above. If you try to run the program on e.g. Windows 7, it will not run. (The same is true for DLLs: If you have a DLL that targets an OS newer than the OS on which you are running, the loader will not load the DLL, at least not for code execution.)

See Wikipedia's page "List of Microsoft Windows versions" for a list of operating system versions. Windows XP is the oldest version of Windows supported by Visual Studio 2013.

The Windows 8 SDK only supports development of software down to Windows Vista. If you want to set _WIN32_WINNT or WINVER to build for Windows XP, you'll need to use the Windows 7 SDK (Visual Studio 2013 will install both SDKs).

Unless your program is substantially different for each target operating system, it would probably be much simpler to build one binary that runs on the oldest operating system you want to support (Windows XP) and either delay-load or dynamically load (via LoadLibrary/GetProcAddress) any functionality that you want to use from newer operating systems, when that functionality is available.

How to install build tools for v141_xp for VC 2017?

I am not entirely clear on whether your issue is installing the C++ tools for Windows XP or modifying your project/solution to target that platform. Either way, the following link should help you out.

Here is a summary on how to install the toolset:

  • Bring up the Visual Studio installer (Tools -> Get Tools and Features)
  • Select Desktop development with C++
  • Select Windows XP support for C++ from the Summary section
  • Click Modify

Sample Image

Sample Image

What does the `Target Platform Version` mean for a VS C++ project?

In Visual Studio 2015 the Target Platform Version field just sets the version of the Windows SDK to use. See this MSDN article for reference. In Visual Studio 2019, this field has been renamed Windows SDK Version. You still need to set _WIN32_WINNT, WINVER, and NTDDI_VERSION macros, as well as the Platform Toolset field. Taken together they determine the versions of Windows your app can run on.

If your applications need to run on Windows XP, you have to pick a Platform Toolset ending in _xp, select an older Windows SDK Version (you need 7.1A, but picking 7.0 or 8.1 should work; see below), and set _WIN32_WINNT, WINVER, and NTDDI_VERSION macros accordingly. See this Stack Overflow posting for tips on setting these macros and including related SDK headers via targetver.h.

If building from a Command Prompt with an _xp platform toolset see this Stack Overflow posting for tips on setting the /SUBSYSTEM linker option and for defining _USING_V110_SDK71_.

Windows SDKs are backward-compatible, but I haven't yet found a clear reference which lists the oldest version of Windows you can target when building with a given version of the Windows SDK (see EDIT at the bottom of this post). Each SDK lists "System Requirements", but these list the minimum version of Windows needed to develop with the SDK, not the minimum version of Windows that executables built with that SDK can target. The best reference I know of is the sdkddkver.h header in each of the newer Windows SDKs. Within this header are a list of _WIN32_WINNT version constants. For example, in the Windows 7.1A SDK, sdkddkver.h defines _WIN32_WINNT_NT4 as the oldest supported Windows platform (but I do not know if this is definitive).

The rest of this answer are notes regarding targeting for native VC++ apps using Visual Studio 2019. These notes may apply to older Visual Studio versions as well.


In Visual Studio 2019, selecting a Platform Toolset which ends in _xp has certain quirks. For v120_xp, the Windows SDK Version field is hidden, but the inherited VC++ Directories will show that the Windows SDK 7.1A directory is specified. For v140_xp and v141_xp platform toolsets, you can pick Windows SDK 7.0 or 8.1 (for either, the inherited VC++ Directories will show that the Windows SDK 7.1A directory is specified).

I am not sure what the difference is - if any - between specifying Windows SDK Version 7.0 or 8.1 when using Platform Toolset v140_xp or v141_xp in Visual Studio 2019.

In Visual Studio 2019, when setting native C++ project properties for a Windows Desktop app, depending on the Platform Toolset you select, the read-only Target Platform field may change to "Windows 10". But this DOES NOT mean your Win32 desktop app will be built as a Universal Windows Platform app. It will still work on older versions of Windows depending on the Platform Toolset, Windows SDK Version and the values for the _WIN32_WINNT, WINVER, and NTDDI_VERSION macros.

Microsoft could update VS2019 so the Target Platform field value would show just "Windows" when setting properties for Win32/desktop projects, regardless of the selected Platform Toolset or Windows SDK Version.

EDIT: See the article A Brief History of Windows SDKs from Chuck Walbourn, Senior Engineer for Xbox at Microsoft, for details regarding backward compatibility of various Windows SDKs.



Related Topics



Leave a reply



Submit