我在 Windows 8.1 上使用 Microsoft Visual Studio 2015.我想编译一个针对 Windows XP 的程序.我在谷歌和其他类似的问题上查过,但没有任何帮助.在解决方案设置中,目标平台工具集设置为 Windows XP 之一,但目标平台版本中没有 Windows XP 的选项.我确实读过
这是因为默认平台工具集使用 Windows 8.1 SDK(或者您可以选择加入 Windows 10 SDK),并且这仅支持为 Windows Vista 或更高版本构建应用程序.当您选择 v140_xp
平台工具集时,您使用的是 Windows 7.1 SDK 的一个版本,这是支持面向 Windows XP 或 Windows Server 2003 的最后一个版本.
请注意,Visual Studio 可以面向 Windows XP Service Pack 3 或 Windows Server 2003 Service Pack 2.C/C++ 运行时与旧版本的 Windows 不兼容.
如果您在应用中使用 DirectX,这会产生一些深远的影响,因为 Windows 7.1 SDK 和 Windows 8 SDK 之间发生了很大变化.请参阅
I'm using Microsoft Visual Studio 2015 on Windows 8.1. I want to compile a program targeting Windows XP. I've looked it up on Google and other similar questions, but none helped. In the solution settings, target platform toolset is set to the Windows XP one, but there is no option for Windows XP in the target platform version. I did read https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx (Using the Windows Headers) and added these lines to my program:
#define WINVER _WIN32_WINNT_WINXP
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#define NTDDI_VERSION NTDDI_WINXP
But it still doesn't work. It says that it can't find "MSVCP140.dll". After I got this dll, it begins to complain about can't find "VC140.dll". After that is "ucrtbased.dll", and then finally "api-ms-win-core-string-11-1-0.dll", which I don't even have it in my Windows 8.1 computer. The program can run on Windows 8.1, but not Windows XP. What can I do to make the program run on Windows XP?
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 thev141_xp
toolset to use with the VS 2019 IDE.
See your Project Properties, the General 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:
这篇关于如何在 Microsoft Visual Studio C++ 中以 Windows XP 为目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!