C++ - 在 Windows 上导入明确专用的模板

发布于 2024-08-06 21:08:21 字数 376 浏览 4 评论 0原文

我在使用 VC2008 SP1 在 Windows 上链接程序时遇到一些问题。 我在 DLL 中显式专门化了一个模板成员函数,该函数在依赖项遍历器中正确显示为导出符号,具有正确的类型和正确的参数。

当我尝试从 .exe 调用符号时,链接器抱怨它无法解析该符号(尽管它可以正常编译对象),但是它表示无法解析的符号的修饰名称与我的 DLL 中导出符号的修饰名称(使用依赖项遍历器查看) 该问题仅发生在显式专用的导出模板成员函数上。如果我注释对这些函数的调用,所有其他导出的函数类将正常链接,因此 .lib 看起来生成正常。

我尝试更改标头中模板函数的声明以包含“extern”指令,并且它正确指定了惯用的 __declspec(dllimport),但这没有什么区别。

任何想法表示赞赏。谢谢。

I am having some trouble getting a program to link on Windows with VC2008 SP1.
I am explicitly specialising a template member function in a DLL, which appears correctly as an exported symbol in dependency walker, for the correct type, and with the correct arguments.

When I try to call the symbol from an .exe, the linker complains that it can't resolve the symbol (although it compiles the object ok), however the decorated name of the symbol it says that it can't resolve exactly matches the decorated name of the exported symbol in my DLL (as viewed with dependency walker) The problem only occurs for explicitly specialised exported template member functions. If I comment the calls to these, all other exported functions classes will link ok, so the .lib looks like it is being generated ok.

I have tried changing my declaration of the template function in the headers to include the 'extern' directive, and it has the customary __declspec(dllimport) correctly specified, but this makes no difference.

Any ideas appreciated. Thanks.

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

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

发布评论

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

评论(1

悲念泪 2024-08-13 21:08:21

最后设法弄清了这个问题的根源 - 这是由没有签入以匹配源代码控制中的 DLL 的 .lib 引起的 - 可能是使用不同的编译器版本构建的。
很抱歉浪费了时间。
...如果所有其他方法都失败,请尝试重建您的库依赖项。

Finally managed to get to the bottom of this - it was caused by a .lib that didn't get checked-in to match the DLL from source control - maybe built with a different compiler version.
Sorry for any wasted time.
... if all else fails, try rebuilding your library dependencies.

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