Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 889
Jon Cage Avatar asked Apr 05 '10 23:04

Jon Cage


1 Answers

What you have missed is most likely that VC++ programs require a runtime to be installed (unless you link statically, which is not the default) - the error message you show is exactly the one you get if they're not in order.

Try installing the Microsoft Visual C++ 2008 SP1 Redistributable Pack on the XP machine - you will most likely see that your program works with no changes whatsoever.

like image 78
Michael Madsen Avatar answered Sep 21 '22 08:09

Michael Madsen