Sign in to follow this  

Unresolved external symbol c_dfDIKeyboard

This topic is 2541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 2541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this