   Direct Input Initialization Problems
  Hi! i''ve been reading OpenGL Game Programming by Dave Astle and Kevin Hawkins,i was just wondering if someone can help me with some problems regardingsetting up DirectX. Direct Input to be specific. I have a windows applicationshell that i work with and that works but for some reason when i try to initializeDirect input and add the codes below, my compiler generates error messages.Also i tried to run programs that the Book has in the cd, the executable versionsrun pretty well and i can see the programs, however their VC++ versions don''t runat all instead where DirectX is concerned they generate error messages similar tothe ones presented below as if the DirectX object wasn''t even defined or included.it may have something to do with my compiler settings but i can''t seem to get myprograms running can anyone help me out?Thanks in advance.Below is the steps i''ve done with my applicationas well as the errors that they generate.The application has a single WinMain.cpp source fileswith a basic framework for creating the window and callback functions along with the message loop but afterthe codes below is added, the errors presented below aregenerated preventing program compilation.//CODESI''ve included  in the .cpp fileI''ve linked with dinput8.h and dxguid.h1.) I''ve declared 2 global variables//Global variablesIDirectInput8 *g_DI;IDirectInputDevice8 *g_DID;2.) These codes are in the Initialize functionwhich in turn are called in my WinMain functionprior to the message loopnote : MB is just a macro for the message box//Initialize Direct InputHRESULT hr = DirectInput8Create(g_hInst, DIRECTINPUT_VERSION,IID_IDirectInput8, (void**)&g_DI, NULL);if (FAILED(hr)){MB("Direct input creation failed!");g_DI->Release();}MB("Direct input initialization OK!");3.) This line is in my ReleaseMemory functionwhich is called after the messageloop hasbeen exited//Release the COM memoryg_DI->Release();//ERRORS1.) syntax error : missing '';'' before ''*''2.) ''IDirectInput8'' : missing storage-class or type specifiers3.) ''g_DI'' : missing storage-class or type specifiers4.) syntax error : missing '';'' before ''*''5.) ''IDirectInputDevice8'' : missing storage-class or type specifiers6.) ''g_DID'' : missing storage-class or type specifiers7.) ''DirectInput8Create'' : undeclared identifier8.) ''IID_IDirectInput8'' : undeclared identifier9.) left of ''->Release'' must point to class/struct/union10.)left of ''->Release'' must point to class/struct/unionThanks for reading. 
  1) First and foremost, make sure you have the DirectX SDK   installed (the end user runtimes or the version which comes with MSVC 6 won''t do). Version 8.0 or above is required by that code.2) In MSVC go to the Tools->Options... menu and click on the Directories tab of the options window then do the following:a. Select "Include files" in the "Show directories for:" listb. Make sure that the path to the include files in the installation of the DirectX SDK is in the list (e.g. C:\DXSDK\INCLUDE). If it isn''t then add it to the list.c. Drag the path of the include files from the DirectX SDK (e.g. C:\DXSDK\INCLUDE) to the ***top***   of that list of paths. This step is very important!  d. Select "Library files" in the "Show directories for:" liste. Make sure that the path to the library files in the installation of the DirectX SDK is in the list (e.g. C:\DXSDK\LIB). If it isn''t then add it to the list.f. c. Drag the path of the library files from the DirectX SDK (e.g. C:\DXSDK\LIB) to the ***top***   of that list of paths. This step is very important!  3) At the top of your source code file you''ll need:#define DIRECTINPUT_VERSION 0x0800#include <windows.h>#include <dinput.h>4) You need to link with dinput8.lib and dxguid.lib - note that''s .lib   not .h  . You set those in Project->Settings...->Link --Simon O''Connorex  -Creative AsylumProgrammer &Microsoft MVP;quote:Original post by S1CA  f. c. Drag the path of the library files from the DirectX SDK (e.g. C:\DXSDK\LIB) to the ***top***of that list of paths. This step is very important!   Many don''t seem to realize just why this is important.Windows standard libs contain old DX stuff, and if the new stuff isn''t searched first by linker, it assumes that you want to use the old libs.This is a source of many errors...Nik ;  To S1CA and Nik02,Thank you very much your help was invaluable.It's working perfectly now.Thanks again for your help, specially for reading such a long message.P.S. Thanks for the step by step illustration S1CA, well appreciated.   [edited by - eisenlewis on August 4, 2003 6:45:56 AM]