vs2008 包括托管 C++来自另一个托管 C++ 中的一个 dll 的类班级?

发布于 2024-09-12 05:38:32 字数 365 浏览 1 评论 0原文

我有一个名为 ManagedWrapper 的项目,它是托管 C++ 并构建为 DLL。

我有第二个项目名为 MyManagedTest,它是托管 C++ 并构建为 DLL。

当我尝试在 MyManagedTest 中包含来自 ManagedWrapper 的标头时,出现链接器 LNK2020 错误。然后,我在“框架和引用”中添加对 ManagedWrapper 的引用,但这会导致编译器错误,指出 ManagedWrapper 中的类已定义(看起来它试图在 MyManagedTest 中再次定义它们,因为我包含了头文件),错误 C2011。

将 ManagedWrapper 中的类包含到 MyManagedTest 中的正确方法是什么?

谢谢。

I have a project called ManagedWrapper that is Managed C++ and builds as a DLL.

I have a second project called MyManagedTest that is Managed C++ and builds as a DLL.

When I try to include a header from ManagedWrapper in MyManagedTest, I get linker LNK2020 errors. I then add a reference to ManagedWrapper in "Frameworks and References" but this causes compiler errors saying that classes in ManagedWrapper are already defined (looks like it is trying to define them again in MyManagedTest because I included header files), error C2011.

What is the proper way to include classes from ManagedWrapper into MyManagedTest?

Thanks.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱我好吗 2024-09-19 05:38:32

您应该对本机类声明使用#include,对托管类声明使用#import。添加引用与#import相同。

顺便说一句,“托管 C++”并不是在 VS2008 中将 C++ 与 .NET 一起使用的正确名称。该功能就是 C++/CLI。 Visual C++ 的早期版本有一个非常错误的语法,称为“C++ 托管扩展”,通常称为“托管 C++”,永远不应该使用。

You should use #include for native class declarations and #import for managed class declarations. Adding a reference is the same as #import.

BTW, "Managed C++" is not the correct name for using C++ with .NET in VS2008. That feature is C++/CLI. Earlier versions of Visual C++ had a very buggy syntax called "Managed Extensions for C++" which was often referred to as "Managed C++" and should never be used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文