Solving hid.lib "unresolved external symbol" linker errors in VC++
Asked Answered
R

1

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?

Ritchey answered 30/9, 2011 at 18:34 Comment(0)
R
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.

Ritchey answered 5/10, 2011 at 20:12 Comment(2)
Thanks for your solution! I just spent almost an hour having the same problem … why don't they say so on MSDN!?Pushup
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.Ritchey

© 2022 - 2024 — McMap. All rights reserved.