CLR dll 需要 C++ .lib 文件,但非 CLR 不需要

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

在一个简单的测试项目中,我有两个C++编译的dll

NonClrDll: 一个普通的 C++ dll(非 /clr

Wrapper: 一个 /clr 编译的 dll,目前只是非托管(本机)代码

要在 C++ 客户端项目中使用 NonClrDll,我所要做的就是包括对 dll 项目的引用和适当的头代码 (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)。我的问题是...

  1. 为什么我不需要包含 NonClrDll 的 .lib 文件?我假设项目参考已经解决了这个问题。是吗?
  2. 如果项目引用应该处理这个问题,为什么我需要为 /clr 编译包装器添加额外的 .lib 文件依赖项?

我相信这是因为 C++/CLI 项目的链接器设置 "IgnoreImportLibrary" 默认为 "Yes" 而本机 C++ 项目默认为 "No"。