Targeting Windows XP with C++ in Visual Studio 2012

We recently announced the Visual Studio 2012 product lineup and platform support, and as a part of this announcement we mentioned that we were evaluating options for enabling C++ developers to build applications in Visual Studio 2012 that run on Windows XP without requiring side-by-side installation of Visual Studio 2010. Today I would like to share more details about this capability.

BackgroundThe C++ runtime and libraries that accompany Visual Studio 2012 contain dependencies on several Windows API functions that exist only on Windows Vista and higher versions of the OS. This means that applications built with Visual Studio 2012’s C++ compiler will fail to load and execute on Windows XP. Developers wishing to target Windows XP can use Visual Studio’s C++ multi-targeting feature, which enables the use of the Visual Studio 2010 compiler from within the new IDE. Multi-targeting enables developers to take advantage of the new features of the IDE without migrating projects to the new compiler or to use the Visual Studio 2010 compiler to build applications that target Windows XP.

Assessing Multi-targetingThe Beta release of Visual Studio 2012 offered us an opportunity to evaluate the effectiveness of C++ multi-targeting, particularly among developers that wish to target Windows XP. Feedback from customers cited two key scenarios they wanted Visual Studio 2012 to support in order to best meet their needs for Windows XP targeting:

The ability to target Windows XP and higher from a single compiler and tools chain rather than resort to separate builds for XP and for Vista+.

The ability to target Windows XP and higher from a single code base that employs modern C++11 language features.

In order to better meet customer needs relative to build configuration and XP targeting, we have made the decision to enhance multi-targeting to support Windows XP targeting directly from the Visual Studio 2012 C++ compiler and libraries.

Enhancing Multi-targetingLater this fall, Microsoft will provide an update to Visual Studio 2012 that will enable C++ applications to target Windows XP. This update will make the necessary modifications to the Visual C++ 2012 compiler, runtime, and libraries to enable developers to create applications and DLLs that run on Windows XP and higher versions as well as Windows Server 2003 and higher. This update will also be included in the recently-announced Visual Studio Express 2012 for Windows Desktop.

I hope DevDiv takes the community's response to ignoring customers' requirements for targeting legacy XP systems with C++11 and a modern toolchain and the Express for Desktop apps debacle to heart and avoids having to make these flip-flop decisions when it is too late for RTM in the future.

The refusal to implement the modern ISO C standards (C11 or even C99) remains as do the terrible all caps menus in the IDE, but I suppose we should count our blessings.

I give you props for listening to your customers and course-correcting. That said, I share GregM's confusion, if it's possible to write C++ 11 code and have it run on XP and up, why would you call it multi-targetting?

Good. Next step: release an update to Windows 8 allowing to get rid of Metro altogether. Trust us: we'll ask loudly and clearly until it happens. Then your telemetry will tell you how bad an idea it was in the first place for desktop PCs.

Now, can you remove the silly 'feature' of LINK.EXE where it refuses to set arbitrary PE ImageVersions? When using a custom-built libc, it kinda sucks having to use old linkers (or post-link exe patching) to get binaries running on win2k. Yes, some of us still support prehistoric windows versions.

Thank goodness. This change and Express for Desktop were the two things that absolutely Had To Happen in this release cycle. Suddenly, Visual Studio 2012 is a viable option again. Without this change, I would not have bought the product; now, I will.

Fantastic! All of a sudden Vs 2012 is a viable option for us again. When XP support is added back in we will almost surely update. Not until then though. Please don't wait too long – we really want to start using some of the newer C++ language features in our code. Thanks Steve!

Oh my god. I don't want to sound harsh, but this is the first truly requested "feature" of VC2012! Not to mention the gradual inclusion of more C++11x features, which makes it the SECOND thing we will get!

@GregM, @Jamome, others: Why "multi-targeting"? Will there be two tool chains in VS2012?

I'm using this term because folks may need to explicitly opt into XP targeting in VS, although there are still a few moving parts in this area, so it will be some weeks before we close on the design. The key point is that developers will be able to target everything from XP to Win8 with one VC++ tool chain.

@Dave Buches: What versions of XP/2k3 will be supported?

The design is not closed on this issue, either. We are aiming for a similar level of platform support to VS2010 (described at msdn.microsoft.com/…/ws0swas0.aspx). We definitely will not support an earlier SP level than VS2010, although the possibility exists that we may require a more recent SP level.

Hi Steve, if you're considering limiting to XP SP3, then please consider supporting XP SP2 also because there is only one extra function that needs to be wrapped/worked around: the GetLogicalProcessorInformation Win32 API, which was added in XP SP3 but is not available in XP SP2.

Thanks a lot for this! We all know that reverting decisions can be hard. Kudos for making the right choice.

After the update which allows targeting XP, VS11 is going to be viable for my team.

What can I say, these blog things seem to work, after all. Hoping for some progress on C++11 now, since both of the reversals are still merely taking VS11 back to where we were with VS10, but you are on the right track, keep going.

Now was that so hard? Of course it was, but whoever caused this problem in the first place is the one at fault. Fire her immediately. I forsee problems coming from this; you can't hack-back in without. It's too late now.

Really great news! You actually listened; I am shocked! I wish the Windows 8 team would listen this well.

You seem to allude that Windows XP support is something that we would need to opt into. You also mention that you were taking advantage of a number of APIs that were Vista+.

This makes me wonder – if I target XP only, are there features of the compiler / language / runtime that will become unavailable? What trade-offs am I making by targeting XP? (Note I am wondering about this from a compiler perspective. Obviously if my app is to run on XP, my source code can't directly use new Vista+ APIs, and I'd imagine there are some newer MFC features I couldn't use. But I don't use MFC.)

@GigaPlex,ildjarn: I would be OK with no GPU acceleration on XP as long as it fell back to CPU mode with no noticeable degradation compared to compiling without AMP. That way, it still works for XP users, but if they really want to get the performance, they need to upgrade to 7.