DLL 和名称修改
我有一个第三方 LIB,其中符号导出为纯 C/cdecl,因此例如 dumpbin.exe /SYMBOLS
报告 __imp_nvmlInit
和 nvmlInit
代码> 已导出。
然而,在 Visual Studio 2010 中,当我尝试导入它们时,头文件将会有,
extern "C" nvmlReturn_t nvmlInit(...);
但当我尝试编译时,出现以下错误:
main.obj:错误LNK2019:函数_main中引用了无法解析的外部符号_nvmlInit
如何阻止 Visual Studio 查找带有前导下划线的符号? __declspect(dllimport)
不起作用,因为它会装饰为 __imp__nvmlInit
(一个下划线太多)。
谢谢。
I have a third-party LIB which has symbols exported as plain C/cdecl, so for example dumpbin.exe /SYMBOLS
reports that both __imp_nvmlInit
and nvmlInit
are exported.
However in Visual Studio 2010 when I try to import them, the header file will have
extern "C" nvmlReturn_t nvmlInit(...);
but when I try to compile, I get the following error:
main.obj : error LNK2019: unresolved external symbol _nvmlInit referenced in function _main
How can I stop Visual Studio from looking for that symbol with a leading underscore? __declspect(dllimport)
doesn't work because then it decorates to __imp__nvmlInit
(one underscore too many).
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个链接器错误。您需要链接与 DLL 关联的 .LIB 文件,这将向链接器承诺,当加载 DLL 本身时,该函数将在运行时可用。
That is a linker error. You need to link with the .LIB file associated with DLL, which will give the linker a promise that the function will be available at run-time when the DLL itself is loaded.