c++dllc++-cli.lib

C++ .lib file required for CLR dll but not for non-CLR


In a simple test project, I have two C++ compiled dlls

NonClrDll: A regular C++ dll (non /clr)

Wrapper: A /clr compiled dll that is only unmanaged (native) code for now

To use the NonClrDll in a C++ client project, all I have to do is include a reference to the dll project and the appropriate header code (as described here). However, to use the /clr compiled wrapper dll, I have to also add the .lib file as an additional dependency (as described here). My questions are...

  1. Why do I not need to include a .lib file for the NonClrDll? I was assuming that the project reference took care of this. Does it?
  2. If the project reference is supposed to take care of this, why do I need to add the additional .lib file dependency for the /clr compiled wrapper?

Solution

  • I believe it is because the C++/CLI Project has the linker setting "IgnoreImportLibrary" defaulted to "Yes" and the native C++ Project it is defaulted to "No".