MS Visual Studio 2012 Express for Windows Desktop - Targeting Windows XP - c++

I have recently upgraded from Visual Studio Express 2010 to Visual Studio 2012 Express for Windows Desktop. I'm aware of the previous lack of compatibility targeting Windows XP, but thought this was resolved by Update 1 (which I have installed).
However, I'm still having difficulty targeting Win XP with the C++ applications I have compiled using 2012 Express. I have set the Platform Toolset to "Visual Studio 2012 - Windows XP (v110_xp)" but this makes no difference. When I try to run my compiled application on my Windows XP system (I run Windows XP via VirtualBox), I get an the error that my application "is not a valid Win32 application."
I have also tried setting the CLR Support to "No Common Language Runtime Support" and the Runtime Library to "Multi-threaded (/MT)".
Even with a very basic blank C++ project using the following code, I just can't get it to run on XP:
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x0501
#include <iostream>
int main()
{
std::cout << "TEST" << std::endl;
std::cout << std::endl << std::endl << "Press ENTER to close this window.";
std::cin.get();
return 0;
}
Can anybody tell me where I'm going wrong with my compiler/project settings?
P.s. I have installed the MS VC++ 2010 and 2012 redistributable packages on my XP virtual machine. Applications that I compiled with Visual Studio Express 2010 work fine on my XP virtual machine.

Check your project's "Configuration Properties -> Linker -> System -> Subsystem" properties.
If blank, fill it with (/SUBSYSTEM:CONSOLE) or (/SUBSYSTEM:WINDOWS).

This works:
Configuration Properties -> Linker -> System -> Subsystem =
/SUBSYSTEM:WINDOWS
Configuration Properties -> General -> Platform Tool Set ->
SubsystemVisual Studio 2012 - Windows XP (v110_xp)
Using Visual Studio 2012 Express Update 3.

Use GNU GCC tool chain, bro, that redistrebuted with mingw. MSVS actualy just minimize dependencies, but some of them still stay in exe. Just compiling in gcc suports full static linking, with small exe size and stable compatibility.

The message is indicating that your build isn't producing a 32 bit application--if it were a version dependent API, for example, you'd see another error indicating that the symbol can't be found. Since you have indicated that you are using the correct target platform in the configuration manager, check your property explorer to make sure you don't have conflicting arguments or defaults. If you see link with the option /MACHINE:X64, then you've found the problem.
If that doesn't work, I suppose you could try running Sysinternals process explorer to see which cl/link are actually being launched with which arguments. Hope that helps.

Related

"is not a valid win32 application" on windows xp

Phenomenon:
Build a c++ program using visual studio express 2015 on windows 7 platform. Copy the executable file to xp system, cannot run with the error"not a valid win32 application"
Have tried two things
go to "configuration properties" and set the "Platform Toolset" to "visual studio 2015 - windows xp(v140_xp)"
go to "configuration Manager" and set the Platform to "Win32" (instead of x64) after these steps, still gives me same problem.
anyone knows what is the root cause of this problem? thank you!
The main problem is the Windows SDK that you are using.
Most recent Windows SDK have a compatibility list that will go far back to Windows 7.
Here are two useful links:
https://blogs.msdn.microsoft.com/vcblog/2015/07/24/setup-changes-in-visual-studio-2015-affecting-c-developers/
Targetting Windows xp from visual studio 2015 enterprise update 1

Visual Studio 2015: building with the Windows XP toolset selected still results in "not a valid win32 application" error on XP

Visual Studio 2015 supports building C++ programs for Windows XP. According to the article Configuring C++11 Programs for Windows XP, enabling this support is simply a matter of selecting the appropriate platform toolset in the project properties.
This does not work in my case. A simple "hello world" program written in C++ and compiled in Visual Studio Community 2015 (version 14.0.24720.00 Update 1) with the platform toolset set to Visual Studio 2015 - Windows XP (v140_xp) and the platform set to x86/Win32 generates the generic "[name of executable] is not a valid Win32 application" error when run on a Windows XP computer.
Any suggestions would be appreciated. I've found a number of questions about similar issues (like these three), but nothing helpful yet.

Building c++ project for Win XP in MSVC 2012

I have a console application that I need to use on Windows XP. Also i'm using MSVC 2012 as an IDE. Problem, that when i run it on Win XP (SP3) i receive error message that this application is not a valid win32 application.
UPD:
After talking care about suggestions in the comments to this question, i've updated my question.
What does use my application:
Urlmon.h/urlmon.lib
boost::program_options
c++11's regex
What i've already tryed:
Build test application like "Hello, World!". It works on target Win XP
Install Update 3 for MSVC 2012 & update 3 redist. to target machine
Build app with static linking (/MT)
Dependency walker shows 3 messages:
Missing WER.dll
Missing IESHIMS.dll
Unresolved C function "WNetRestoreConnectionA"
As far as i see nothing of listed in dependency walker should affect my app, but it still fail to load with error "not a valid win32 application".
Does anyone have ideas why>
The v110_xp toolset automatically specifies the SUBSYSTEM's MRV ("5.1" (WindowsXP)) but not the SUBSYSTEM
That was the problem. I've set SUBSYSTEM to "/SUBSYSTEM:CONSOLE" in project settings & problem with target Win XP dissapeared. Thanks everyone for comments.
As I know, MSVC 2012 toolset do not support windows XP. But you can use MSVC 2010 toolset in IDE 2012. Or use toolset v110_xp forom Visual Studio 2012 Update 1(I didn't try it).
This link may help
http://blogs.msdn.com/b/vcblog/archive/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-2012.aspx?Redirected=true

How do I compile for Windows XP with Visual Studio 2012?

Ok, so I'm using Visual Studio 2012 in Windows 7 x64 for programming and compiling. My application works fine there, but when I try to execute it from a Windows XP SP3 Virtual Machine, I get "xxxx.exe is not a valid win32 application" right away.
The application is being compiled with static linking, that is, with /MT. I have set _WIN32_WINNT to 0x0501 in targetver.exe; the configuration manager is set to Win32 and the target machine in the Linker advanced options is set to MACHINEX86.
My targetver.h looks like this:
#include <winsdkver.h>
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x0501
#include <SDKDDKVer.h>
I also tried compiling with /MD and installing .NET Framework, but that didn't help either.
I'm clueless, and I could really use some help as I need to have it working for Windows XP.
VC++ 2012 RTM did not support Windows XP – that support came later in 2012 in Visual Studio 2012 Update 1.
The CTP of Windows XP targeting with VC++ 2012 could be installed, but you would have to link the CRT statically in order to deploy. See this blog article for more information.
Visual Studio 2012 Update 1 added official support for running applications built with VC++ 2012 on Windows XP as well as the ability to link the CRT dynamically.
Download link
Blog article containing additional information
Two things should be done:
Configuration Properties → General page, change Platform Toolset to: Visual Studio 2012 - Windows XP (v110_xp);
Menu Linker → System. Change Subsystem to: Console/Windows.
A detailed explanation is here: http://software.intel.com/en-us/articles/linking-applications-using-visual-studio-2012-to-run-on-windows-xp
When you generate the EXE file, the version for 32-bit will be in the project folder bin\x86\Release.

visual studio 2008 C++ no x64 platform

I installed Visual Studio 2008 on my Windows 7 x64 laptop together with installation of Service Pack 1.
Now I want to add x64 platform to my C++ solution. But there is no x64 platform available in the configuration manager for my project. I'm sure I manually selected x64 support during the Visual Studio installation and it was installed.
What is wrong with my setup?
If I recall, VS 2008 Pro doesn't install the 64-bit compiler and tools by default. You have to explicitly select them during the installation.
Control Panel -> Uninstall Programs.
Select Visual Studio and click Uninstall/Change.
Wait. Wait some more. Click Next.
Choose Add or Remove Features.
Expand MSVC 2008 -> Language Tools -> Visual C++.
Select X64 Compilers and Tools.
You'll probably need your original installation media.
Once the 64-bit compiler and tools are installed, you should be able to add a 64-bit configuration to your solution.
See "Use Visual Studio to build 64-bit application" for all you need to build x64 apps with Visual Studio 2008.
Visual Studio 2008 only comes with x64 compiler with the Professional editions and higher. You can download the free Windows SDK from MSDN to get the x64 compiler.
If your projects don't have the x64 configuration, just add that configuration via the configuration manager. I don't remember if 2008 created the x64 configuration by default but I suspect not.
I also seem to remember that you can just add the x64 configuration to the solution and it will prompt on whether or not to add it to all of the contained projects but my memory is rusty on that one.
Regardless, once you've got the configurations added, you'll need to modify anything you'd modified before in project settings. Output paths, library dependencies, etc. The New Configuration "Wizard" is pretty dumb.