briggs_w
asked on
DirectInput: sample code won't link in C++, is missing _IID_IDirectInput8A
I find that like my code, the sample code for DirectX 9.0 -- specifically, DirectInput -- won't link. The file I am trying is C:\DirectX\Samples\C++\Dir ectInput\d input.dsw (your path may vary, but it does come with the distribution).
error LNK2001: unresolved external symbol _IID_IDirectInput8A
Under project: settings, link tab, I find that dinput8.lib is being linked in. I have tried having it link dxguid.lib as well, but this has not helped.
The line in _my_ code that offends is a call:
DirectInput8Create(appInst ance,
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void **)&m_pDI,
NULL)
According to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/input/ref/functs/directinput8create.asp, IID_IDirectInput8 is #defined as _IID_IDirectInput8A or _IID_IDirectInput8W.
I am at a college; the PC's in our lab have the same problem -- but the students say they don't have this problem at home. (My urgency: some rely on the lab, and they're hitting this problem.) I am using MS Visual C++ 6.0 and also Visual .NET (same problem).
Thanks!
error LNK2001: unresolved external symbol _IID_IDirectInput8A
Under project: settings, link tab, I find that dinput8.lib is being linked in. I have tried having it link dxguid.lib as well, but this has not helped.
The line in _my_ code that offends is a call:
DirectInput8Create(appInst
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void **)&m_pDI,
NULL)
According to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/input/ref/functs/directinput8create.asp, IID_IDirectInput8 is #defined as _IID_IDirectInput8A or _IID_IDirectInput8W.
I am at a college; the PC's in our lab have the same problem -- but the students say they don't have this problem at home. (My urgency: some rely on the lab, and they're hitting this problem.) I am using MS Visual C++ 6.0 and also Visual .NET (same problem).
Thanks!
Btw, the directories might already be set, for both libraries and include, but just check.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It would seem I completely mis-read that problem :) I guess I read it and decided to ignore the text.
Also, does DIRECTINPUT_VERSION get defined by default anywhere? Should be 0x0800
Also, does DIRECTINPUT_VERSION get defined by default anywhere? Should be 0x0800
Since I really spoke without thinking earlier, maybe this will help also.
I can only think that perhaps the directories are not setup correctly, but then I'd also imagine more would be erroring, however check to make sure that your directX lib folder and include folder are above the default visualstudio folders, and that there IS an entry for the directX lib folder in the library directory setting.
I can only think that perhaps the directories are not setup correctly, but then I'd also imagine more would be erroring, however check to make sure that your directX lib folder and include folder are above the default visualstudio folders, and that there IS an entry for the directX lib folder in the library directory setting.
But why is that needed, jkr?
Normal c++ program shouldn't need it...
Normal c++ program shouldn't need it...
ASKER
(_corey_, I assume you mean directories put under Tools, Options, Directories tab? Done.)
jkr: It works! I am so relieved (and mystified). BTW, to get it to work I had to make this slight alteration (as the compiler directed me):
#include <objbase.h>
#define INITGUID
#include <initguid.h>
jkr: It works! I am so relieved (and mystified). BTW, to get it to work I had to make this slight alteration (as the compiler directed me):
#include <objbase.h>
#define INITGUID
#include <initguid.h>
>>and mystified
No need to be 'mystified' :o)
No need to be 'mystified' :o)
ASKER
Explain, and I (and _corey_ it seems) won't be!
Sorry for the delay, but the secret simply is that the actual memory allocation has to be done just in one .obj module, so these #ifdef's control where.
(Sorry again, totally missed your comment)
(Sorry again, totally missed your comment)
Then, in the project settings, linker, you need to add dinput8.lib and maybe dxguid.lib