添加来自本机 C++ 的引用VS2010 中的 C++/CLI DLL 的 DLL 不会将导入库添加到链接器命令行吗?

发布于 2024-10-20 23:55:45 字数 709 浏览 1 评论 0原文

我有一个有点奇怪的问题,我似乎无法弄清楚。我们有一个基本上是非托管的 C++ 应用程序,它已经存在了一段时间,因此是使用许多不同版本的 Visual Studio 构建的,并且定期更新到当前版本的 Visual Studio。

我现在遇到了以下问题:

  • 在 VS2010 中,我向现有解决方案添加了两个新项目。这两个新项目都是 DLL,其中一个是用普通的非托管 C++ 构建的,混合使用 C++ 和 C++/CLI 构建,因此是使用 CLR 支持 (/clr) 构建的。第二个 C++/CLI DLL 应该由系统的其他几个组件使用
  • 使用属性 ->通用属性->在框架和参考中,我将两个新 DLL 添加为第三个 DLL 的依赖项。第三个 DLL 对 .NET 没有任何了解,并且是用纯本机、非托管 C++ 实现的。新的 DLL 在依赖项设置中正确显示,并且新引用在解决方案的构建顺序受到影响(正确)的意义上起作用,但由于某种原因,仅将普通本机 C++ DLL 的导入库添加到引用这两个库的 DLL 的链接器命令行。第二个混合库生成一个导入库,但 VS2010 不会将导入库添加到链接器命令行,这可以预见会导致几个无法解析的外部符号。
  • 似乎触发此行为的一个设置是构建具有公共语言运行时支持的 DLL,因为库的所有其他设置都是相同的。

我目前有解决此问题的方法 - 我只需将导入库添加为手动依赖项 - 但我想知道其他人是否遇到过此问题,以及是否有一种方法可以使此功能按预期工作而无需解决方法?

I have a somewhat odd problem that I don't seem to be able to get to the bottom of. We have a mostly unmanaged C++ application that's been around for a while and thus has been built using lots of different versions of Visual Studio, with it being updated to the current version of Visual Studio on a regular basis.

I've now run into the following issue:

  • In VS2010 I've added two new projects to the existing solution. Both new projects are DLLs, one built in plain unmanaged C++, the built using a mix of C++ and C++/CLI and is thus built with CLR support (/clr). The second C++/CLI DLL should be used by several other components of the system
  • Using Properties -> Common Properties -> Framework and References, I add the two new DLLs as a dependency to a third DLL. The third DLL is doesn't know anything about .NET and is implemented in pure native, unmanaged C++. The new DLLs show up correctly in the dependency settings and the new references work in the sense that the build order of the solution is affected (correct), but for some reason, only the import library for the plain native C++ DLL is added to the linker command line for DLL that references both libraries. The second, mixed library generates an import library, but VS2010 doesn't add the import library to the linker command line which predictably results in several unresolved external symbols.
  • The one setting that appears to trigger this behaviour is building the DLL with Common Language runtime support as all the other settings of the libraries are identical.

I currently have a workaround for this issue - I simply add the import library as a manual dependency - but I was wondering if someone else has encountered this problem and if there is a way to get make this feature work as expected without the workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文