views:

593

answers:

2

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.

+4  A: 

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
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
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
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
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
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
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
Great! My favourite kind of problem is the one that isn't there. 8-)
RichieHindle
A: 

Look here, here and here

Shay Erlichmen
Thanks but I think those 3 threads address slightly different questions (albeit they do resemble this somewhat)
Steffen
I didn't say those are the same questions, just used the as reference.
Shay Erlichmen