views:

92

answers:

5

I'm new to c++. I made a c++ program using VS 2008 Professional. I started with the Win32 template that created a window for me. I compiled it on Vista 32. I brought the compiled exe to my old XP sp2 computer, and it tells me the application configuration is incorrect. Is there something im doing wrong? How do I make it platform independent?

Thanks

+2  A: 

Try installing Microsoft Visual C++ 2008 SP1 Redistributable Package and make sure you use the release build of your application.

Hrvoje Prgeša
Then how could I make an application with no dependencies, this is a bit dissapointing because I transitioned from .Net with hopes of not having to worry about this stuff; can I just use VC 6 or something?
Milo
You can avoid the dependency by statically linking to the runtime support libraries.
Michael Burr
A: 

Your target system is missing the needed runtime files for that executable.

You can find it at: Microsoft Visual C++ 2008 Redistributable Package (x86) or Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)

crashmstr
+1  A: 

Make sure that WINVER is set to a version that includes WinXP - it looks like the default target version of Windows for VS 2008 is Vista (0x0600).

Set the following preprocessor define:

#define WINVER 0x0501

preferably using the Project Properties "C/C++/Preprocessor/Preprocessor Definitions" or the -D option on the cl.exe command line. It's also possible that there's a targetver.h file that has this setting (depending on how your project got created initially).

See http://msdn.microsoft.com/en-us/library/aa383745(VS.85).aspx for more details.

Michael Burr
That is a good idea to do, but probably not the problem based on the error that is occurring.
crashmstr
A: 

You could use Dependency Walker to find which components lacks on target WinXP system. Then you should install appropriate redistributables.

Kirill V. Lyadvinsky
A: 

In project properties, set "C/C++ -> Code Generation -> Runtime Library" to "Multi-threaded (Debug)". After you rebuild, the application will no longer depend on msvcr90.dll. The application binary will, however, be somewhat larger.

avakar
Of course, for release builds you should use "Multi-Threaded" (not debug). Also this is a bad idea if your app itself consists of multiple DLLs.
MSalters