Problems linking with MinGW (v.4.3.0) and libhid

非 Y 不嫁゛ 提交于 2019-12-02 11:10:09

I've just found the answer. I'm posting an answer myself so that other people know in future, because I think this is still a valid question which people might want to know about.

The problem is the include file hidsdi.h. The majority of other header files which pull in Win32 API calls have extern "C" around the function declarations. However this one doesn't! The result is that we end up with C++ name mangling for linker symbols, instead of the C-style "_" in front of the linker symbols.

The solution is to use

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

and then everything works fine.

The version of hidsdi.h with the older version of MinGW (which I'm porting from) did have that protection around the function declarations. However it looks like it's gone in the newer version.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!