views:

39

answers:

3

Which headers should I not use if I don't want my program to be linked with any of msvc*.dll ?

At the moment my application uses:

  1. kernel32
  2. user32
  3. shell32
  4. msvcp90
  5. msvcr90

I want to get rid of the bottom two files. I don't mind if I will have to rewrite certain aspects of the program.

Because I know if you code in C and then link it won't link any msvc's

A: 

Those libraries contain the C++ runtime - heap management and other stuff hard to get rid from.

You could link the C++ statically instead - use "C++ -> Code Generation -> Runtime Library" setting. Then you will not need those .dll files. However this is not the recommended way - if a vulnerability is found in the C++ runtime you'll have to recompile and reship your program.

sharptooth
+1  A: 

I believe you have to change the way the CRT is linked into your program. I think for that you have to change the C++->Code Generation->Runtime-Library to the static version. This is for Visual Studio 2005, don't know about newer versions.

Space_C0wb0y
It's all the same in 2k3, 2k5 and 2k8.
sharptooth
102 kb O.o that is huge. Is there a way to make a light statically linked program?
Nick Brooks
The best bet is to turn on "Progress messages" in linker settings and look into what objects it links and why. That might give you ideas of what to change in the program.
sharptooth
@Nick: Yes, use LIBCTINY (google it)
MSalters
A: 

Static link is the right answer. A related bit of advice is to use depends.exe to see what functions your exe is actually hitting in the dependent dlls. Those dependencies might be due to explicit use on your part or due to CRT implementation that you don't explicitly invoke.

sean e