Solved

DirectInput: sample code won't link in C++, is missing _IID_IDirectInput8A

Posted on 2003-11-12
10
1,697 Views
Last Modified: 2013-12-03
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++\DirectInput\dinput.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(appInstance,
                               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!
0
Comment
Question by:briggs_w
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 8

Expert Comment

by:_corey_
ID: 9737100
You need to add the lib folder to the library list in the options menu of Visual Studio.

Then, in the project settings, linker, you need to add dinput8.lib and maybe dxguid.lib
0
 
LVL 8

Expert Comment

by:_corey_
ID: 9737131
Btw, the directories might already be set, for both libraries and include, but just check.
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 9740807
Have you used

#define INITGUID
#include <initguid.h>

before including the DirectX headers?
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 8

Expert Comment

by:_corey_
ID: 9741966
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
0
 
LVL 8

Expert Comment

by:_corey_
ID: 9742565
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.
0
 
LVL 8

Expert Comment

by:_corey_
ID: 9742895
But why is that needed, jkr?

Normal c++ program shouldn't need it...
0
 

Author Comment

by:briggs_w
ID: 9742952
(_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>
0
 
LVL 86

Expert Comment

by:jkr
ID: 9742980
>>and mystified

No need to be 'mystified' :o)
0
 

Author Comment

by:briggs_w
ID: 9748453
Explain, and I (and _corey_ it seems) won't be!
0
 
LVL 86

Expert Comment

by:jkr
ID: 10101382
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)
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question