c++ - 在 VC++ 中解决 hid.lib "unresolved external symbol"链接器错误

标签 c++ visual-c++ linker-errors .lib

如标题所示,我遇到以下链接器错误:

error LNK2019: unresolved external symbol "unsigned char __stdcall HidD_GetAttributes(void *,struct _HIDD_ATTRIBUTES *)" (?HidD_GetAttributes@@YGEPAXPAU_HIDD_ATTRIBUTES@@@Z)

在我的代码中调用 result = HidD_GetAttributes(WriteHandle, &attributes) 时。

这个函数应该存在于“hid.lib”中,我已将其添加到项目的链接器依赖项中。我还包含了头文件“hidsdi.h”,它具有 HidD_GetAttributes 的函数原型(prototype)。

我认为唯一可能有问题的是“hid.lib”的函数原型(prototype)分为三个不同的头文件:hidsdi.h、hidpi.h 和 hidsage.h。

有什么建议吗?

最佳答案

刚刚解决了这个问题。显然,“hid.lib”是用 C 语言编写的,这导致了一些名称混淆。使用

extern "C"
{
    #include "hidsdi.h"
}

清理一切。

关于c++ - 在 VC++ 中解决 hid.lib "unresolved external symbol"链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7614606/

相关文章:

c++ - realloc 错误而不是 malloc?

c++ - 带有参数的 Visual C++ 2010 解决方案范围的宏

c++ - 如何从 IE 中隐藏自定义工具栏

c - undefined reference 'getchar_unlocked' 错误

ios - 体系结构 x86_64 的 undefined symbol - 我可以在设备上构建和运行,但不能在模拟器上构建和运行

c++ - HBITMAP 可以包含 alpha channel 信息吗?

c++ - 距离路由 vector 实现

c++ - C++中的坐标系

c++ - 在 C++ 程序中跟踪 Win32 API 调用

c - "undefined reference to function"C 中的错误取决于定义的位置