tags:

views:

174

answers:

2

I have a C++ application only taking use of the basic Win32 API (I can remove that too if neccessary) and the C++ STL. I'm using MSVC and want it to be really standalone. I have already tried several options (including using the "Multithreaded" option instead of "Multithreaded DLL").

Yet: It misses several MSVC runtime DLLs on many computers including those in my school.

  • How can I create a C++ application able to run on Windows XP (and lower/higher if possible) without needing any specific DLL versions only avaiable with Service Packs and runtime-DLLs installed?

Do I have to switch to G++?

My requirements aren't that big.. Just a small executable, 35KB in size, containing some loops here and some ifs there.

+3  A: 

If you use static linking for all libraries you use, you should not need any DLLs. Are you sure you're not using MFC or ATL DLLs or something? Setting the runtime library to 'multithreaded' instead of 'multithreaded DLL' should do the trick for the CRT and remove any dependency on the MSVCRT DLLs. There should be a similar setting in general properties, like "use standard windows headers".

If you're using Visual Studio 2010, the CRT requires Windows XP SP2 or newer (so RTM or SP1 won't work). If you need to target prior to XP SP2, you probably need to go back down to Visual Studio 2008.

AshleysBrain
+3  A: 

Well, you already found the option you need to change. Right-click the project in the Solution Explorer window, Properties, C/C++, Code Generation, Runtime Library = /MTd. The resulting EXE only has a dependency on kernel32.dll, Windows.

Don't forget to also do this for the Release build configuration. Now choose /MT.

Hans Passant
Self-quote: *I have already tried several options (including using the "Multithreaded" option instead of "Multithreaded DLL").* That means I've tried but it didn't make the result "standalone".
My name goes here.
Self-quote: *Don't forget to also do this for the Release build configuration*
Hans Passant
@My name goes here: then you did something else wrong. There's not much more any of us can say: @Hans told you what setting removes the dependency on the runtime dll, if you still have a dependency on that dll, you've done something wrong. I don't keep my psychic debugging skills on on weekdays, so you'll have to actually give us some information then about what you're doing.
jalf
@jalf: When do you keep your psychic debbuging skills on ? Might be useful to know ! (I have some really mind-blowing bugs to find from time to time)
ereOn
@jalf: Psychic debugging skills? Really? Now that 50K reputation is not nearly so impressive!
ravenspoint