Sign in to follow this  

Linking problem with Direct X - d3dx9.h

This topic is 2636 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

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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
I do wish more tutorials would mention the #pragma comment (lib, "blabla.lib"), much easier for a beginner. Having it in code makes it more tangible, trying to stuff in a lot of information about how linking works etc when you're still trying to get interested in coding is a real motivation killer.

And more tutorials should guide users trough MSDN, how to find the library to link against for the functions they use.

But thats just my two cents :)

Share this post


Link to post
Share on other sites

This topic is 2636 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