2

I have some source that can compile with MINGW gcc or with VC++ (but isn't in a VS project, it has a makefile that is read by nmake). I compile with nmake and it produces a static lib and I would like to compile the code as a DLL to use with my managed assemblies.

Is it trivial to alter the makefile to output a DLL instead of the static? Or do I need to somehow wrap the static lib in a DLL? I apologize because I'm sure this has been answered before but I've never had to do this before and not sure where to start reading. I'm not finding what I think I need on SO either, even though it's most likely asked/answered already.

Jeff LaFay
  • 12,882
  • 13
  • 71
  • 101

1 Answers1

3

A wrapper is probably the way to go here. You'd create a Managed C++ DLL which links to the static lib. Then you could call the Managed C++ DLL from other managed assemblies.

o. nate
  • 384
  • 1
  • 3
  • Is it as simple as you're making it sound? Will I need to explicitly define types and method signatures or can I just link the lib and be good to go? – Jeff LaFay Nov 04 '10 at 20:07
  • It's not that simple. You'd need to write the wrapper methods. Those methods would be declared as managed code. Inside those managed methods, you would call the unmanaged methods (and perform any transformations of the arguments if needed). – o. nate Nov 05 '10 at 17:33
  • How about classes? Is it possible to write a wrapper class to encapsulate ones found in the static lib? – Jeff LaFay Nov 08 '10 at 19:46
  • Yes, you could write wrapper classes. For more details, I'd recommend this topic: http://stackoverflow.com/questions/425752/managed-c-wrappers-for-legacy-c-libraries – o. nate Nov 09 '10 at 21:37