having trouble with dinput.h

This is a discussion on having trouble with dinput.h within the Game Programming forums, part of the General Programming Boards category; Hi I started implementing direct input into my program for the first time and started recieving a bunch of link ...

  1. #1
    Registered User Boomba's Avatar
    Join Date
    Jun 2003
    Posts
    89

    Angry having trouble with dinput.h

    Hi

    I started implementing direct input into my program for the first time and started recieving a bunch of link errors while I have dinput.h included. NOTE: I have made the neccissary changes according to your sticky thread about BASETSD.H to fix compatability issues with visual C++ 6.

    these are the errors i recieve:

    Compiling...
    dx_init.cpp
    c:\program files\microsoft directx 9.0 sdk (october 2004)\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
    dx_mesh.cpp
    Linking...
    dx_init.obj : error LNK2001: unresolved external symbol _c_dfDIMouse
    dx_init.obj : error LNK2001: unresolved external symbol _GUID_SysMouse
    dx_init.obj : error LNK2001: unresolved external symbol _c_dfDIKeyboard
    dx_init.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboard
    dx_init.obj : error LNK2001: unresolved external symbol _DirectInput8Create@20
    dx_init.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8A
    any ideas as to what I did wrong? i'm kinda stumped since msdn says al these things are apart of the dinput library.

    thanx in advance
    Boomba,

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Well the first error is happening because you must define DIRECTINPUT_VERSION.

    Code:
    #ifndef CDINPUT
    #define CDINPUT
     
    //You MUST define this PRIOR to including dinput.h
    #define DIRECTINPUT_VERSION 0x0800
    #include <dinput.h>
     
     
     
     
    class CDInput
    {
    protected:
    IDirectInput8 *_pDI8;
    public:
    CDInput() { };
    		CDInput(HINSTANCE hinst) {Init(hinst);};
    ~CDInput() { };
     
    HRESULT Init(HINSTANCE hinst);
    		void ShutDown(void) {if (_pDI8) _pDI8->Release();};
    		IDirectInput8 *GetInterface(void) {return _pDI8;};
    };
    #endif
    The second error is happening because...I think....since you have not defined DIRECTINPUT_VERSION it is not sure which library to link with ---------- OR you are not correctly linking with dinput.lib or dinput8.lib. I had to link with both dinput8.lib and dinput.lib to get my code to work correctly.

    Trust me I was so frustrated with DirectInput when I created my classes I wished I had never ever heard of the thing. I ran into the same errors you did on my first try.

  3. #3
    Registered User Boomba's Avatar
    Join Date
    Jun 2003
    Posts
    89
    thank you very much Bubba! that got rid of all the link errors

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with assignment in C
    By mohanlon in forum C Programming
    Replies: 17
    Last Post: 06-23-2009, 10:44 AM
  2. Replies: 6
    Last Post: 01-03-2007, 02:02 PM
  3. Is it so trouble?
    By Yumin in forum Tech Board
    Replies: 4
    Last Post: 01-30-2006, 03:10 PM
  4. trouble scanning in... and link listing
    By panfilero in forum C Programming
    Replies: 14
    Last Post: 11-21-2005, 11:58 AM
  5. C++ program trouble
    By senrab in forum C++ Programming
    Replies: 7
    Last Post: 04-29-2003, 11:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21