模板类遇到__declspec(导入)时链接器错误 [英] Linker error when template class meets __declspec(import)

查看:72
本文介绍了模板类遇到__declspec(导入)时链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在一个非常具体的情况下观察链接器错误,涉及从模板实例化继承的类的dllexport。

I'm observing the linker error in a quite specific scenario, involving the dllexport'ing the class inherited from the template instantiation.

简而言之,这就是我的情况:

In a nutshell, here's the situation I have:

1)3个项目(我们将它们命名为A,B,C),依赖图如下:B-> ; A,C-> B,C-> A.
2)在项目A中,我们定义了一个模板类。它在该项目的标题中得到实例化。
$
3)项目B中的DLL导出类,它继承自2)的模板类的相同实例。

4 )项目C至少有两个翻译单位,其中至少有一个包括2)和3)。

1) 3 projects (let's name them A,B,C) with dependency graph like this: B->A, C->B, C->A.
2) In project A we define a template class. It gets intantiated within the header of that project A.
3) DLL-exported class in project B which inherits from the same intantiation of template class from 2).
4) Project C with at least two tranlation units, at least one of them includes both 2) and 3).

我不想在这里复制信息,所以我会给一个链接到stackoverflow的问题 (https://stackoverflow.com/questions/45133791/visual-studio-linker-error-when-template-class-meets-declspecimport)(它包含一些代码示例)和github
存储库(https://github.com/4sily/VisualStudioLinkerIssue),其中包含repro-case和问题的详细描述。

I don't want to duplicate info here, so I'll give a link to my question at stackoverflow (https://stackoverflow.com/questions/45133791/visual-studio-linker-error-when-template-class-meets-declspecimport) (it contains some code samples) and to the github repository (https://github.com/4sily/VisualStudioLinkerIssue) which contains the repro-case and the detailed description of the problem.

推荐答案

嗨4sily,

Hi 4sily,

感谢您在这里发帖。

这个论坛是关于MSBuild的,因为您的问题与C ++编程语言更相关,我们帮助您将其移至

C ++编程语言
论坛以获得更好的支持。

This forum is about the MSBuild, as your issue is more related to the C++ programming language, we help you move it to C++ programming language forum for better support.

如果您有一些MSBuild问题,请随意联系我们我们将尽力为您提供解决方案。

If you have some MSBuild questions, please feel free to contact us. We will try our best to give you a solution.

感谢您的理解与合作。


这篇关于模板类遇到__declspec(导入)时链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆