#### Archived

This topic is now archived and is closed to further replies.

This topic is 6030 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I attempted to compile the program demo8_3.cpp from Tricks of the Windows Game Programming Gurus by André LaMothe, where there are asteroids bumipng around the edges of the screen. Unfortunately, i had a compilation error. I included ddraw.h and ddraw.lib, and I have DirectX8.0. I get the following errors: C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(50) : error C2065: ''LPDIRECTDRAWSURFACE4'' : undeclared identifier C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(50) : error C2146: syntax error : missing '')'' before identifier ''lpdds'' C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(50) : error C2059: syntax error : '')'' C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(71) : error C2146: syntax error : missing '';'' before identifier ''lpdd'' C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(71) : error C2501: ''LPDIRECTDRAW4'' : missing storage-class or type specifiers C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(71) : fatal error C1004: unexpected end of file found How can I fix these? These are straight from the book. I know there should be an LPDIRECTDRAWSURFACE4, but apparently, my compiler doesn''t recognize it. Thanks, Maneesh

##### Share on other sites
It sounds like you haven''t linked to the Direct Draw libraries. (I am at school so I don''t have my compiler handy, but I will post back on how to fix it when I get home).

##### Share on other sites
No Moe, as I said, I included ddraw.lib as it was required by Mr. Lamothe. That isn''t the problem.

-Maneesh

##### Share on other sites
You havent included the *correct* directX headers.
You need to reconfigure your compiler to look in the correct place (where you installed the SDK) otherwise it will just use the default ones, which only go as far as DX3.

If you are using MSVC, go tools->options->directories, select include files from the dropdown box, add a new directory and make sure you shift it to the top of the search order. Do the same for library files or youll get a similar linker error later.

##### Share on other sites
I already did that, I have been able to compiile other DIretX progams. In MSVC++, i have it set to C:\Program FIles\Directx\SDK\include and lib. I even tried including every single DirectX library, but it still didn''t work. That isn''t the problem. By the way, it recognizes LPDIRECTDRAW SURACE, but it doesn''t recognize LPDIRECTDRAWSURFACE4

-Maneesh

##### Share on other sites
I had similar problems to this in the past but ran out of time so never came up with a solution. However, if I can be a bit constructive I think it is to do with the fact that the demos in the book are all created for directx version 6.1. Now, there is something that needs to be added to the dx6.1 source code to get dx8 to compile it correctly. I think it''s something to do with setting the version but I don''t know the exact details. Possibly somebody can help out here if I''m on the right track.

Hope this helps

henry

##### Share on other sites
Thanks a lot KVH, it fixed the problem. But now there are new errors and warnings. NOw there is 3 errors and 55 warnings. The erros are:

D:\Maneesh\GameProgrammingSource\T3dchap12\t3dlib2.cpp(83) : error C2065: ''DirectInputCreate'' : undeclared identifier
D:\Maneesh\GameProgrammingSource\T3dchap12\t3dlib2.cpp(110) : error C2065: ''DIDEVTYPE_JOYSTICK'' : undeclared identifier
d:\maneesh\gameprogrammingsource\t3dchap12\t3dlib3.h(64) : error C2065: ''DSBCAPS_CTRLDEFAULT'' : undeclared identifier

How do I fix these errors. I have included dinput.h and dinput.lib and ddraw.h and ddraw.lib

##### Share on other sites
right above #include "dinput.h"

#define DIRECTINPUT_VERSION 0x0?00

where ? is the version you want

Robert Warden
Lasershot Shooting Simulations

##### Share on other sites
No that didn''t work either. Its as if these things don''t exist!

##### Share on other sites
In DX8, they changed a few things. DirectInputCreate became DirectInput8Create, I believe, and DIDEVTYPE_JOYSTICK became DI8DEVTYPE_JOYSTICK, but I''m not entirely sure about these. They also decided to no longer #define DSBCAPS_CTRLDEFAULT. Try this:
#define DSBCAPS_CTRLDEFAULT (DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN)

##### Share on other sites
Well, Almost. It wouldn''t take away the DirectDrawCreate thuohg. Maybe I just need to get DirectX7.0!

Thanks

-Maneesh

##### Share on other sites
(...I apologize in advance for the length of this message...)

Try these:

A) Make sure the new directories for DirectX are above the other directories as it includes the first one it runs into

B) got to your include directory. open up dinput.h in notepad. Search for 'DirectInputCreate'. If it doesn't find it you don't have valid headers. I use the DX8 sdk but directinput 5 so i KNOW this works. also there are still legacy versions of constants in dinput.h

(stripped from dinput.h)
  #if DIRECTINPUT_VERSION <= 0x700#define DIDEVTYPE_DEVICE 1#define DIDEVTYPE_MOUSE 2#define DIDEVTYPE_KEYBOARD 3#define DIDEVTYPE_JOYSTICK 4#else#define DI8DEVCLASS_ALL 0#define DI8DEVCLASS_DEVICE 1#define DI8DEVCLASS_POINTER 2#define DI8DEVCLASS_KEYBOARD 3#define DI8DEVCLASS_GAMECTRL 4#define DI8DEVTYPE_DEVICE 0x11#define DI8DEVTYPE_MOUSE 0x12#define DI8DEVTYPE_KEYBOARD 0x13#define DI8DEVTYPE_JOYSTICK 0x14..........#endif /* DIRECTINPUT_VERSION <= 0x700 */

also

  #if DIRECTINPUT_VERSION > 0x0700extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter);#elseextern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter);extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter);#ifdef UNICODE#define DirectInputCreate DirectInputCreateW#else#define DirectInputCreate DirectInputCreateA#endif // !UNICODE

but aprosenf is correct about DSBCAPS_CTRLDEFAULT

Robert Warden
Lasershot Shooting Simulations

Edited by - KlePt0 on June 8, 2001 4:32:18 PM

##### Share on other sites
Well, all the directories are set up correctly, but it still doesn''t work. KlePt0 had exactly the same header as me, so that isn''t the problem. I even tried changing DirectDrawCreate to DirectInputCreateW and DirectInputCreateA, but it still doesn''t work. If anyone wants, I can send the files to them!

Thanks
-Maneesh

##### Share on other sites
Make totally abosutely sure that the directx include/lib directories are at te top of the search list. This is the kind of common sense error everyone makes.

I am sure.

##### Share on other sites
email me later and i''ll help you through it this weekend. Right now i''m a little busy though.

Robert Warden
Lasershot Shooting Simulations

• ### Forum Statistics

• Total Topics
628642
• Total Posts
2983998

• 9
• 9
• 10
• 21
• 20