Unresolved external symbol c_dfDIKeyboard

Started by
1 comment, last by Jon Hellebuyck 13 years, 3 months ago
Hello everyone.

So, I'm doing this DirectInput exercise I found in a book, and I'm getting a compile time error in Visual C++ 2010 Express. These are my errors:

DI Ex.obj : error LNK2020: unresolved token (0A000015) c_dfDIKeyboard
DI Ex.obj : error LNK2001: unresolved external symbol c_dfDIKeyboard
...that comes from this line:
hr = lpKeyboard->SetDataFormat(&c_dfDIKeyboard);

I've linked with dinput8.lib and dxguid.lib. My includes are windows.h, objbase.h, initguid.h, and dinput.h.

If its of any consequence, I've created a CLR app (first time, its a learning experience) and am using unmanaged DirectX. I really don't want to attempt switching to (and learning) managed DX unless you guys think that this is absolutely my problem.

I've searched around with Google, but I can't find crap, just the "you forgot to link dxguid.lib," and since I've linked that, I don't know what the deal is.

I have also looked into creating my own data format for the keyboard, but I can't find anything detailed. The DI sample "CustomFormat" included with the SDK is particularly useless, as it glosses over everything that appears to be important.

Well if you guys have any advice, I'd appreciate it if you share! Thanks!
Advertisement
After posting I created a regular Win32 solution and (along with the libs and includes) added the lines:

LPDIRECTINPUTDEVICE lpkb;
lpkb->SetDataFormat(&c_dfDIKeyboard);

and everything compiled just fine, so I guess Managed C++ is the issue here. :S

Still, if anyone has a workaround or any type of fix or a link to a tutorial on setting up custom data formats for keyboards, I'd appreciate it very much!
I used to get that error when compiling with Borland, but I'm surprised you're seeing it with MS Visual C++.

The fix for Borland was a library file called c_dinput.lib. The keyboard (as well as mouse) constants are defined as "extern" in dinput.h, but for some reason the reference wasn't in dinput8.lib if you made a Borland-compatible version. Again, I'm not sure you should need this file with a Microsoft compiler, but it's something to try anyway.

The other thing I thought I read about with initguid.h was that if you include it before any of your D3D headers you don't need to add dxguid.lib to your project. Sounds like that's counter to what others have told you though.

This link talks about initguid.h

http://support.microsoft.com/kb/130869

I'm sorry all of this is so vague. It's been a while since I've researched this error. I hope some of this helps.

Jon Hellebuyck - Mode13.com

This topic is closed to new replies.

Advertisement