How do I compile for windows XP under windows 7 / visual studio 2008

Posted by Jon Cage on Stack Overflow See other posts from Stack Overflow or by Jon Cage
Published on 2010-04-05T23:23:28Z Indexed on 2010/04/05 23:33 UTC
Read the original article Hit count: 259

I'm running Windows 7 and Visual Studio 2008 Pro and trying to get my application to work on Windows XP SP3.

It's a really minimal command line program so should have any ridiculous dependencies:

// XPBuild.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
    printf("Hello world");
    getchar();
    return 0;
}

I read somewhere that defining several constants such as WINVER should allow me to compile for other platforms. I've tried the added the following to my /D compiler options:

;WINVER=0x0501;_WIN32_WINNT 0x0501;NTDDI_VERSION=NTDDI_WINXP

But that made no difference. When I run it on my Windows XP machine (actually running in a virtualbox) I get the following error:

This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

So what have I missed? Is there something else required to run MSVC compiled programs or a different compiler option or something else?

© Stack Overflow or respective owner

Related posts about c++

Related posts about windows-xp