How to get Visual C++ 2012 Update 2 statically linked applications to run on Windows XP

EDIT (June 26, 2013) – Microsoft has released the final version of Visual Studio 2012 Update 3 that completely fixes this issue.  For more information on Update 3, please click here.

EDIT (May 11, 2013) – Microsoft has released an RC of Visual Studio 2012 Update 3 that fixes this issue which is “go live”, meaning if you can’t wait for the final Update 3 and need a Microsoft supported solution immediately, you can use it with production releases.  For more info look here and to download look here. For a solution to use with Update 2, see below.

Due to a regression in Visual C++ 2012 Update 2, applications using ATL will no longer be able to run on XP, even if using built-in XP targeting support.  This is due to a new dependency on InitializeCriticalSectionEx.  Running an app on XP that was built with Visual C++ 2012 Update 2 will give you the following error message:

Entry Point Not Found

The procedure entry point InitializeCriticalSectionEx could not be located in the dynamic link library KERNEL32.dll

To fix this, I’ve published a new version of the xpsupport tool, namely XPSupport for VC11 Update 2 Version 1.02, on my skydrive.  It simply wraps the InitializeCriticalSectionEx function with an XP compatible replacement, using techniques I’ve used in previous blog entries.

To use this solution, simply add build customizations (masm) to your project by right clicking on the project in solution explorer and choosing “build customizations” and check masm (targets, props) on, then add the three files (xpatl.cpp, xpatlwrap.asm, and xpatlwrap64.asm) contained in the zip file named: xpsupportvc11upd2v102.zip found here:

https://skydrive.live.com/redir?resid=1B361BF333E9AB82!153&authkey=!AEAOQJ4-LCqWQiw

Build your app, and now your app will run under XP.

EDIT: despite the title of this blog post, I received reports that this works also for dynamically linked apps (i.e. linking to MFC and the CRT dynamically)

More info about the cause found here:

http://social.msdn.microsoft.com/Forums/en-US/visualstudiogeneral/thread/f0477c9f-8a2c-4e6b-9f5a-cd2469e216c4

credits to VSBs and others for reporting and researching this issue.

changelog:

1.00 2013-04-14 Initial Release

1.01 2013-04-15 added x64 support

1.02 2013-04-17 cleaned up Vista check

Advertisements