문제

I want to create a C++ program with Visual Studio 2013 targeted for the XP environment, I am aware of the UI option in Project Properties -> Configuration tab to set the the Platform Tool set top Windows v120_xp, I want to acheive that using the command line options. How to do that.

For visual studio 2012 I am aware of the option

set CL=/D_USING_V110_SDK71_;%CL%

I am looking for similar option is Visual Studio 2013. Can you please help?

도움이 되었습니까?

해결책

The _USING_V110_SDK71_ macro has nothing to do with building your program to be compatible with XP, it is merely a side-effect. The essential option is a linker option, /SUBSYSTEM. Note how this option lets you specify the major and minor sub-system version number. Your program can only run on XP if you set this option to 5,1. Starting with VS2012, the default setting is 6,0 which is the version number of the current generation of Windows. Vista or higher is required to run such a program.

This is actually rather a big deal, downgrading the version number turns on some app-compat shims in Windows that were designed to deal with a program that announces that it doesn't know anything about a modern Windows version. Particularly the way Aero lies about the window metrics, designed to allow an ancient program to still run with fat window borders.

The CRT is also affected, fairly obscure details related to threading and localization. Testing is required of course. Keep the cost of supporting such an ancient operating system in mind.

Last but not least, you also need to use an appropriate SDK version. The last one that's still compatible with XP is v7.1. If you build from the command line then you'll get 8.1, you need to fix that by setting the %WindowsSdkDir% environment variable first. And you need to set the target Windows version in your headers that #include Windows.h, hopefully a precompiled header. Define _WIN32_WINNT to 0x501 to match XP and avoid accidentally using winapi functions that are not available on XP.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top