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:
开发者_JAVA百科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.
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.
精彩评论