6

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.

6
  • Check your target platform in Build -> Configuration Manager.
    – shf301
    Jan 13, 2013 at 18:50
  • You can certainly run programs compiled with VC 10 toolchain on XP. That's essentially the same as compiling with VS 2010, but you didn't state that you need VC 11 toolchain in the question. Jan 13, 2013 at 19:29
  • @shf301 - Target platform is Win32.
    – Colin
    Jan 13, 2013 at 20:09
  • @VioletGiraffe - By "toolchain", do you mean "toolset"? I'm using a bit of C++11 so I'm assuming that I need to use VC 11 to compile. What I can't understand is why setting the Toolset to v110_xp doesn't do the trick. Even starting a new project and using the default settings with v110_xp doesn't work.
    – Colin
    Jan 13, 2013 at 20:12
  • @Colin: Yes, my bad, it's toolset. You may or may not need v110, depends on what exactly bit of C++ 11 you need. Haven't tried v110 on XP so can't help there. The error is the same as when VC++ redist package is missing, though. Jan 13, 2013 at 20:36

4 Answers 4

1

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

1

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.

1

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.