Linking problem with Direct X - d3dx9.h

Started by
9 comments, last by marius1930 13 years, 6 months ago
I have a bit of a complicated linking problem concerning Direct X. I have installed the latest SDK (June 2010) and I'm attempting to learn Direct X using a code listing in the book Beginning Game Programming, Third Edition.

But my problem is that Visual C++ 2010 doesn't seem to recognize d3dx9.h exists unless I implicitly tell i where the SDK includes and libs are in my project. Any other .h file is fine. But when I have done this I get the errors -

1>MyDirecX.obj : error LNK2001: unresolved external symbol _c_dfDIMouse
1>MyDirecX.obj : error LNK2001: unresolved external symbol _GUID_SysMouse
1>MyDirecX.obj : error LNK2001: unresolved external symbol _c_dfDIKeyboard
1>MyDirecX.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboard
1>MyDirecX.obj : error LNK2019: unresolved external symbol _DirectInput8Create@20 referenced in function "bool __cdecl DirectInput_Init(struct HWND__ *)" (?DirectInput_Init@@YA_NPAUHWND__@@@Z)
1>MyDirecX.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8A
1>MyDirecX.obj : error LNK2019: unresolved external symbol _XInputGetState@8 referenced in function "void __cdecl DirectInput_Update(void)" (?DirectInput_Update@@YAXXZ)
1>MyDirecX.obj : error LNK2019: unresolved external symbol _XInputGetCapabilities@12 referenced in function "bool __cdecl XInput_Controller_Found(void)" (?XInput_Controller_Found@@YA_NXZ)
1>MyDirecX.obj : error LNK2019: unresolved external symbol _XInputSetState@8 referenced in function "void __cdecl XInput_Vibrate(int,int)" (?XInput_Vibrate@@YAXHH@Z)
1>C:\Documents and Settings\Jesse\My Documents\Visual Studio 2010\Projects\LearnGame\Debug\LearnGame.exe : fatal error LNK1120: 9 unresolved externals

I had installed an earlier version of direct X along with the latest version. But after all these problems I had uninstalled the earlier one and reinstalled the latest. With no avail but I still think it is related to the problem some how.

Does anyone have any help with this problem?
Thanks

Advertisement
Quote:unless I implicitly tell i where the SDK includes and libs are in my project

You have to set the include directories and library paths, as well as add the appropriate libraries to the linker input.

Are you saying you're doing all that and still getting errors?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Yes I am. But d3dx9.h is the only one I had to implicitly set the includes and Libraries for. Visual C++ 2010 sees the rest fine with out me even touching the directories for include and library look up
best guess u forgot to link agains XInput.lib along with dinput8.lib
or u linking the wrong versions(different sdk or x86/x64)
Crazy dude smoking D3D11, AngelScript, PhysX, 3D Sound, Network, DB, FBX, and some other weird things, doing that on Visual Studio 2010 + Visual Assist X on Overclocked CPU
Have you defined DIRECTINPUT_VERSION in your project?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Yep. I have it set to DIRECTINPUT_VERSION 0x0800 and I have been using the x86 lib's
Are you linking dxguid.lib?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Everything should be linked. From what I understand Visual C++ Express 2010 has you just select a directory and I selected C:\Program Files\Microsoft DirectX SDK (June 2010)\Lib\x86.

This is why I'm starting to hate direct X. Over the years I have tried again and again to learn it, but something always impedes my progress and it usually involves the lib files.
Quote:Original post by ssdko2004
Everything should be linked. From what I understand Visual C++ Express 2010 has you just select a directory and I selected C:\Program Files\Microsoft DirectX SDK (June 2010)\Lib\x86.
You need to add the path to the lib files in Visual Studio, then link in each .lib file seperately. You can't just point Visual Studio at an entire directory and have it link in everything in that library.

You should add the path in your Visual Studio directories (That's for VC2005, but 2010 will be similar), and then in project settings (Alt+F7) -> Linker -> Input -> Additional Dependencies, you should add dinput8.lib, dxguid.lib and xinput.lib.

Quote:Original post by ssdko2004
This is why I'm starting to hate direct X. Over the years I have tried again and again to learn it, but something always impedes my progress and it usually involves the lib files.
This isn't a DirectX thing, you'd have this issue with any library.

Also, I don't know what the book does with DirectInput, but you'll want to stay away from using DirectInput for keyboard or mouse input. I'm not saying to ignore any code in the book that does that, it's still a useful thing to know - I just wouldn't ever use DirectInput for keyboard or mouse input in a real-world application.
I can't believe I forgot to do that Evil Steve.

Thanks, with everyone's help I got it to compile.

This topic is closed to new replies.

Advertisement