Windows XP Targeting with C++ in Visual Studio 2012

Background

In June, we announced enhanced targeting for Windows XP using the Visual Studio 2012 C++ compiler and libraries. This feature has been included in Visual Studio 2012 Update 1. You can download it from here. The purpose of this article is to provide an overview of the Windows XP targeting experience, the level of C++ runtime support, and noteworthy differences from the default experience shipped in Visual Studio 2012 at RTM.

Windows XP Targeting Experience

In order to target Windows XP, switch from the default v110 toolset to the newly introduced v110_xp toolset inside your project’s property pages. This new platform toolset points to a repackaged version of the Windows 7 SDK shipped in Visual Studio 2010 instead of the Windows 8 SDK, but uses the same Visual Studio 2012 compiler. The v110_xp toolset also sets useful defaults such as a compatible linker subsystem version for downlevel targeting. Only executables built with this platform toolset are supported to run on Windows XP, but those same executables will also run on Vista, Windows 7 and Windows 8. 

正在上传…重新上传取消icon-default.png?t=M1L8https://devblogs.microsoft.com/cppblog/wp-content/uploads/sites/9/2012/10/7725.xptarget.png

C++ Runtime Support

The static and dynamic link libraries for the CRT, ConCRT/PPL, STL, and MFC have been updated in-place to add runtime support for Windows XP and Windows Server 2003. Applications written in C++/CLI which target the .NET Framework 4.0 will also run on Windows XP and Windows Server 2003. For these operating systems, the supported versions are Windows XP SP3 for x86, Windows XP SP2 for x64, and Windows Server 2003 SP2 for both x86 and x64.

Library

v110 (Vista+)

v110 (Store Apps)

v110_xp (XP/2k3+)

CRT

X

X

X

ConCRT/PPL

X

X

X

STL

X

X

X

MFC

X

X

ATL

X

X

X

C++ AMP

X

X

Differences from Vista+ Targeting

  1. Building HLSL
    Building HLSL with the v110_xp toolset is not enabled by default. To enable HLSL compilation, download the DirectX SDK (June 2010) and set your project’s VC directories manually to point to this SDK, in a similar manner as Visual Studio 2010. For more information, see the “DirectX SDK Does Not Register Include/Library Paths with Visual Studio 2010” section of the DirectX SDK (June 2010) download page.
     
  2. Debugging DirectX
    The Visual Studio 2012 Graphics Debugging experience is not supported when targeting DirectX 9.
     
  3. Static Analysis
    When selecting the v110_xp platform toolset, the static analysis experience is disabled due to incompatibilities between the SAL annotations in the Visual Studio 2012 C++ libraries and the Windows 7 SDK. If static analysis is required, we recommend that you switch the solution to the normal v110 toolset, execute static analysis, and then switch back to v110_xp.
     
  4. Remote Debugging
    The Remote Tools for Visual Studio 2012 do not support remote debugging on an XP client. When debugging on Windows XP is required, it is recommended to use the debuggers of an older version of Visual Studio, such as Visual Studio 2010, for local or remote debugging. This is in line with the Windows Vista experience for Visual Studio 2012 RTM, which is a runtime target but not a remote debugging target.
  5. Process Status APIs
    As with Visual Studio 2012 RTM, applications that target Windows Vista and below while taking a dependency on the process status APIs must set  the PSAPI_VERSION macro to 1.

Targeting from the Command Line

Visual Studio 2012 solutions and projects which have been switched to the v110_xp toolset can be built from the command line using MSBuild or DEVENV without additional steps. 

However, if you wish to use CL and Link directly, additional steps are needed. Note that the steps below may be automated by creating a batch script.

  1. Set the path and environment variables for Visual Studio 2012 command-line builds. 
  2. Set the required SDK paths and compiler flags using the following commands:

    set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%
    set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%
    set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%
    set CL=/D_USING_V110_SDK71_;%CL%

    When targeting x64, set the lib path as follows:
    set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib\x64;%LIB%
     

  3. Specify the correct subsystem and subsystem version for the linker based on the type of application you are building. Applications targeting the x86 version of Windows XP must specify subsystem version 5.01, and applications targeting x64 must specify version 5.02.

    For x86 console applications: 
    set LINK=/SUBSYSTEM:CONSOLE,5.01 %LINK%

    For x64 console applications:
    set LINK=/SUBSYSTEM:CONSOLE,5.02 %LINK%
     

  4. Execute CL and Link as you normally would within the command prompt.

Feedback

As always, we’d love to hear your feedback. Please submit bugs to Visual Studio Connect, and suggestions to Visual Studio UserVoice.

### 关于 Visual Studio 和 Itanium 架构的相关开发工具或配置方法 Visual Studio 提供了一系列针对不同硬件架构的开发支持,其中包括对 Itanium 的支持。然而需要注意的是,随着技术的发展和市场需求的变化,微软逐渐减少了对某些老旧架构的支持,因此在较新的版本中可能无法找到专门面向 Itanium 的选项。 #### 配置方法 为了在 Visual Studio 中构建适用于 Itanium 架构的应用程序,可以按照以下方式设置编译器和链接器参数: 1. **平台目标选择** 在 Visual Studio 的项目属性页面中,可以通过 `Configuration Manager` 添加一个新的平台配置。对于 Itanium 支持,通常会有一个名为 `IA64` 的选项可供选择[^1]。如果该选项不可见,则可能是当前安装缺少必要的组件。 2. **修改生成文件中的依赖项** 如果项目涉及静态库或其他二进制资源,在 `build.gradle` 文件或者类似的构建脚本中需指定这些资源也应适配 Itanium 平台。例如: ```gradle build.gradle { executables { main { binaries.all { // Ensure each executable binary links against IA64-specific libraries. binary lib libraries.hello.static.forArchitecture('ia64') } } } } ``` 3. **调试信息处理** 当涉及到 Itanium 调试时,特别要注意其特有的调试符号格式。根据已有资料提到的内容,“此部分包含 Visual C++ 调试信息(符号信息)。对象仅限于 `.debug$P` 类型。” 这意味着开发者应当确认所使用的调试工具能够解析此类特定于 Itanium 的符号表结构[^3]。 #### 工具链需求 除了调整 IDE 设置外,还需要确保本地环境已正确安装适合 Itanium 开发所需的 SDKs 及框架版本。值得注意的一点是“.NET Framework 客户端版不足以满足全部功能需求,并且预发布版本可能导致兼容性问题”。因此建议采用稳定发布的全功能版.NET Framework 来保障整个开发生命周期内的稳定性[^2]。 另外关于远程过程调用(RPC),特别是分布式计算场景下的接口定义语言(IDL)方面,由于DCOM采用了扩展后的MIDL标准来描述跨网络边界交互所需的数据序列化逻辑。“这种机制基于DCE/RPC相同的NDT协议实现”,并引入了一个新概念即代理/存根模型用于封装实际通信细节[^4]。尽管这主要应用于COM+服务领域,但对于复杂的企业级解决方案而言仍具有重要价值。 ```cpp // Example of defining an IDL file for use with MIDL compiler targeting Itanium architecture. [ object, uuid(00000000-0000-0000-C000-000000000046), pointer_default(unique) ] interface IMyInterface : IUnknown{ HRESULT MyMethod([in] long param1, [out,retval] BSTR *result); }; ``` 以上代码片段展示了如何通过自定义IDL接口适应特殊处理器体系结构的要求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

偶是江湖中人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值