C++ 如何使用 Visual Studio 2012 为 Windows XP 进行编译?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13130713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I compile for Windows XP with Visual Studio 2012?
提问by WiperWoper
Ok, so I'm using Visual Studio 2012 in Windows 7 x64 for programming and compiling. My application works fine there, but when I try to execute it from a Windows XP SP3 Virtual Machine, I get "xxxx.exe is not a valid win32 application" right away.
好的,所以我在 Windows 7 x64 中使用 Visual Studio 2012 进行编程和编译。我的应用程序在那里运行良好,但是当我尝试从 Windows XP SP3 虚拟机执行它时,我立即收到“xxxx.exe 不是有效的 win32 应用程序”。
The application is being compiled with static linking, that is, with /MT
. I have set _WIN32_WINNT to 0x0501 in targetver.exe; the configuration manager is set to Win32 and the target machine in the Linker advanced optionsis set to MACHINEX86.
应用程序正在使用静态链接编译,即使用/MT
. 我已经在 targetver.exe 中将 _WIN32_WINNT 设置为 0x0501;配置管理器设置为Win32,链接器高级选项中的目标机器设置为MACHINEX86。
My targetver.h looks like this:
我的 targetver.h 看起来像这样:
#include <winsdkver.h>
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x0501
#include <SDKDDKVer.h>
I also tried compiling with /MD
and installing .NET Framework, but that didn't help either.
我还尝试使用/MD
.NET Framework 进行编译和安装,但这也无济于事。
I'm clueless, and I could really use some help as I need to have it working for Windows XP.
我一无所知,我真的可以使用一些帮助,因为我需要让它在 Windows XP 上工作。
采纳答案by ildjarn
VC++ 2012 RTM did notsupport Windows XP – that support came later in 2012 in Visual Studio 2012 Update 1.
VC++ 2012 RTM不支持 Windows XP——该支持于 2012 年晚些时候在 Visual Studio 2012 Update 1 中提供。
The CTP of Windows XP targeting with VC++ 2012could be installed, but you would have to link the CRT statically in order to deploy. See this blog articlefor more information.
可以安装面向 VC++ 2012 的 Windows XP的CTP,但您必须静态链接 CRT 才能部署。有关更多信息,请参阅此博客文章。
Visual Studio 2012 Update 1 added official support for running applications built with VC++ 2012 on Windows XP as well as the ability to link the CRT dynamically.
Visual Studio 2012 Update 1 添加了对在 Windows XP 上运行使用 VC++ 2012 构建的应用程序的官方支持以及动态链接 CRT 的能力。
回答by Aliaksei Plashchanski
Two things should be done:
应该做两件事:
Configuration Properties→ General page, change Platform Toolsetto: Visual Studio 2012 - Windows XP (v110_xp);
Menu Linker→ System. Change Subsystemto: Console/Windows.
配置属性→常规页面,将平台工具集更改为:Visual Studio 2012 - Windows XP (v110_xp);
菜单链接器→系统。将子系统更改为:Console/Windows。
A detailed explanation is here: http://software.intel.com/en-us/articles/linking-applications-using-visual-studio-2012-to-run-on-windows-xp
详细解释在这里:http: //software.intel.com/en-us/articles/linking-applications-using-visual-studio-2012-to-run-on-windows-xp
回答by Cesar
When you generate the EXE file, the version for 32-bit will be in the project folder bin\x86\Release
.
生成 EXE 文件时,32 位版本将位于项目文件夹中bin\x86\Release
。