简体   繁体   中英

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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM