Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual C++11 executables and Windows XP [duplicate]

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 226
Norbert Willhelm Avatar asked Nov 26 '22 02:11

Norbert Willhelm


2 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 77
Anders Avatar answered Nov 27 '22 17:11

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 25
RichieHindle Avatar answered Nov 27 '22 15:11

RichieHindle