5

As the title suggests, I am having the following linker error:

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

when calling result = HidD_GetAttributes(WriteHandle, &attributes) in my code.

This function should exist in "hid.lib" which I have added to my linker dependencies for the project. I have also included the header file "hidsdi.h" which has the function prototype for HidD_GetAttributes.

The only other thing that I thought might be problematic is that the function prototypes for "hid.lib" are split between three different headers: hidsdi.h, hidpi.h, and hidsage.h.

Any suggestions?

Ben
  • 1,092
  • 1
  • 14
  • 33

1 Answers1

9

Just solved the problem. Apparently "hid.lib" was written in C which was resulting in some name mangling. Using

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

cleared everything up.

Ben
  • 1,092
  • 1
  • 14
  • 33
  • Thanks for your solution! I just spent almost an hour having the same problem … why don't they say so on MSDN!? – Felix Dombek Oct 24 '11 at 23:13
  • from my experience, microsoft's documentation is not that great. most of the problems i had were fixed by messing around with my code or searching forums. glad this was helpful to you. – Ben Oct 25 '11 at 16:15