What is special about the executables compiled with Visual Studio 11 which results in that the executables cannot be executed on Windows XP?

社会主义新天地 提交于 2019-11-27 21:04:51
Anders

They seem to drop support for older systems in every new release of VS (NT4,2000,XP) Even if you don't use the CRT at all, they still force the PE subsystem version to high numbers. You can work around that by changing the numbers back to 5.0 in a post build step. Just changing those numbers should allow the exe to start on XP unless the new CRT is using WinAPI functions that don't exist on XP.

The other alternative if you want to keep using VS11 is to use multi-targeting and older compilers...

Visual Studio 2012 will be able to target Windows XP later in 2012:

Targeting Windows XP with C++ in Visual Studio 2012

"Later 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."

Edit: This has now happened (phew!)

The workaround is to use a different Platform Toolset, which will link a different version of CRT and produce binaries compatible to older operating systems.

See more here: Target Windows XP in Visual Studio 11 Beta using the Visual Studio 2010 compiler and libraries.

With v90 toolset your binary will be able to run even in older systems, such as Windows 2000.

http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-69/7444.BlogPic.png

The runtime libraries bundled with VS 2010 and higher enforce your executable to import two new functions from kernel32.dll that are missing on Windows XP: EncodePointer and DecodePointer. Those are needed for yet another idiotic naive attempt to enhance the software "security".

In VS 2010 there is an option to use the runtime libraries of Visual Studio 2008, which solves this problem. I don't know if there's such an option in later versions of VS.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!