0

I have added the c++ dll in to my c# application by using the(Dllimport)Pinvoke functionality.I have build the project with vs2015 with Microsoft Redistributing Visual C++ Files and it worked fine and then i have copied the generated bin folder in to another machine it doesn't have visual studio and visual c++ files but the still sample is working.

Are c++ run time library are mandatory for using imported dll in C++ application? or when building the application will the c++ run time library be added as a resource in a dll?

James Z
  • 12,209
  • 10
  • 24
  • 44
Mohan Selvaraj
  • 236
  • 2
  • 15
  • 2
    It depends how you built the DLL. Does it link to the runtime dynamically, or statically? That was a choice you made. – David Heffernan Mar 07 '18 at 10:01
  • Building the DLL with /MT is okay if the DLL does not use any other DLLs. – Hans Passant Mar 07 '18 at 10:03
  • i am accessing the c++ dll in c# application by providing the dll path in dllimport during the runtime. – Mohan Selvaraj Mar 07 '18 at 10:06
  • 1
    C# doesn't matter to this question here, it depends on how the C++ DLL is built as suggested by David Hefferman. – huysentruitw Mar 07 '18 at 10:07
  • 1
    https://stackoverflow.com/a/14752373/1300910 – huysentruitw Mar 07 '18 at 10:10
  • When you built the DLL, how did you link the runtime? That's a setting determined in the project options in VS. – David Heffernan Mar 07 '18 at 10:16
  • Thanks for the stackoverflow link the msvcp110.dll has been installed in the machine in the c drive windows folders which is equivalent to C++ standard library.so the sample is working fine with out c++ run time library – Mohan Selvaraj Mar 07 '18 at 11:24
  • Installing the redistributable is a one time thing. So if a computer has installed *any* program (Office, web browser, game, utility, whatever) using a specific compiler version, any other program built using the same compiler will also work. – Bo Persson Mar 07 '18 at 11:32
  • 1
    You still don't seem to have grasped that you need to know whether your linked to the runtime statically or dynamically. You have to know that information. Why don't you know it? – David Heffernan Mar 07 '18 at 11:50

0 Answers0