6

I'm trying to build a simple .Net wrapper around some basic C++ code.

The C++ code does not rely on anything in the vcredist dlls, so I'm wondering if I can setup my project, so it doesn't require those dlls to work ?

I'd hate to have my users download and run vcredist, just for a simple DLL to work.

Steffen
  • 13,648
  • 7
  • 57
  • 67

1 Answers1

10

You need to link your DLL with the "Use the CRT as a static library" option:

Project properties / Configuration / C/C++ / Code Generation / Runtime library / Multithreaded (ie. not any of the "DLL" options).

RichieHindle
  • 272,464
  • 47
  • 358
  • 399
  • This seems like the right approach, however when I set it to /MT it complains that this is incompatible with /clr - which I presume is necessary to build the .Net class (the wrapper for the native C++ class) – Steffen Jul 19 '09 at 09:28
  • Ah, that's probably true. But if your users need .Net, is it reasonable to assume they'll also have the relevant CRT DLLs? – RichieHindle Jul 19 '09 at 09:32
  • Well they'll obviously have the CRT DLLs, it's the MSVCR90.DLL and similar I'm worried about - the VC++ specific stuff. If I try to run an application using this DLL as it is, it'll complain about not finding MSVCR90.DLL :-( (Unless you've installed vcredist or visual studio) – Steffen Jul 19 '09 at 09:36
  • MSVCR90.DLL *is* the CRT DLL... you'll probably find you're OK without doing anything. The thing to do would be to set up a clean Windows VM, install the known prerequisites of your software (.Net and whatever else it needs) and then try your DLL - it'll probably just work. – RichieHindle Jul 19 '09 at 19:16
  • Ok my bad about what is the CRT DLL - what I meant was the ordinary .Net stuff (mscorlib and so forth). I'm installing a clean Windows VM as I write, and will let you know whether it works or not. It's just in the past I've always had to install vcredist to run anything compiled with VC++. Anyway I'll keep you informed :-) – Steffen Jul 20 '09 at 18:06
  • I've tried it out now, and it actually works on a clean VM. So I guess the solution is simply to not worry about it :-) – Steffen Jul 21 '09 at 14:58
  • Great! My favourite kind of problem is the one that isn't there. 8-) – RichieHindle Jul 21 '09 at 15:11