Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I compile my C++ source code with Visual Studio 11 Developer Preview. I statically link to the runtime library.

The resulting executable cannot be executed on Windows XP. When I try to execute it on Windows XP I get the error message "[Executable Path] is not a valid Win32 Application.".

According to Microsoft Visual Studio 11 won't support Windows XP.

How does it work that the resulting executable cannot be executed on Windows XP? Is there anything special within the executable?

like image 584
Norbert Willhelm Avatar asked Oct 09 '11 09:10

Norbert Willhelm


3 Answers

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

like image 183
Anders Avatar answered Oct 17 '22 21:10

Anders


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!)

like image 20
RichieHindle Avatar answered Oct 17 '22 21:10

RichieHindle


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

like image 4
Roman R. Avatar answered Oct 17 '22 22:10

Roman R.