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


Starting Directx

Recommended Posts

Kaezin    158
Okay I got the book Tricks of the Windows Game Programming Gurus, and managed to get all the way to the DirectDraw part (that''s an accomplishment for me! =D), but now I don''t know how to configure VC++ for it (or at least I think that''s my problem). I am getting the following errors: C:\Game\Game.cpp(59) : error C2146: syntax error : missing '';'' before identifier ''lpdd4'' C:\Game\Game.cpp(59) : error C2501: ''LPDIRECTDRAW4'' : missing storage-class or type specifiers C:\Game\Game.cpp(59) : fatal error C1004: unexpected end of file found Error executing cl.exe. I have the Directx 8 SDK and put in the include directory of the DX8 SDK in the project options. I also put in the ddraw.lib in the project options. But now I have no idea what to do... can anyone help? It''s probably some stupid thing that I did (I''m used to it)

Share this post

Link to post
Share on other sites
Sheep    152
This is taken from the "Hands on forum." I couldnt get it to work, but after reading this it did. If you want to read it directly just go to the forum... its under the "Readiness Test" topic.

Tell the IDE Where to Look

Move to Tools|Options|Directories , and you’ll see a list of locations that the IDE searches through when looking for project files. We’re not talking about our files here – they’re all in the project’s directory and therefore easy for the IDE to find. No, what the compiler is really going to have a hard time finding without our help is all of the DirectX header files that we intend to use.

So, here’s what you do. Where did you install your DirectX SDK? Mine is at C:\DXVCSDK , so I’ll use that as an example (substitute with your own). All of the DirectX header files are located in the INCLUDE subdirectory, so you’d add an entry like this to the list:


Now that you have it in the list, and this is very important, move the entry up until it’s the very first one. The reason for this is because MSVC comes with some older DirectX header files, and if the IDE looks in the MSVC default directories before trying yours, things will be screwed-up.

Tell the Linker Where to Look

The IDE may now know where all of the header files are (in our project directory and in the DirectX SDK include directory), but it also needs to know where the ‘real’ DirectX code libraries are. After all, the header files only contain prototypes (kind of like usage instructions) for the DirectX components – the components themselves are in DLL files on your system. What the linker needs to do is know which libraries (files with linking instructions) are needed for our project. We’ll be looking at compiling and linking in a later article, but for now here’s what I’m talking about:

Our project uses these files:




…which contains prototypes for the DirectDraw, DirectInput and DirectSound components we’re using. The actual components (the DirectX runtimes) are called:




…which are the files that everyone has for playing DirectX games with. Finally, we have library files that connect code using DirectX components:




Okay, so just read this next sentence very carefully and you’ll be fine: Our source code is compiled with instructions contained within header files, and linked with instructions contained in library files, which ultimately allow our code to use the components in the runtime (DLL) files.

So, where was I? Oh yeah… Head to Project|Settings|Link , and you’ll see an edit field called Object/library modules . You may even see some entries already here, all ending in .LIB. All we need to do is add our library files here, and they happen to be located in a directory called LIB inside our main DirectX folder. What I do is add this to the front of the library list:


If there are other libraries in this list already, leave them after yours (separated by a space). Now, there happens to be one other library that we’re using (for our sound code), so you’ll need to add WINMM.LIB to this list as well. So, to recap, let’s say that when you first showed up in this dialog, the edit box showed something like:


(Whatever their names actually are, who cares). Now it should be:


Got it?

Share this post

Link to post
Share on other sites
Kaezin    158
Okay that solved the problem (I think), but now I have these two errors:

Game.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw4
Debug/Game.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

I''ve had these errors before when I tried to compile some other projects, I have NO IDEA what the hell I should do about it... I don''t know how to fix it either.

Share this post

Link to post
Share on other sites
Kaezin    158
Here is my library thing from VC++:

c:\dx6\lib\ddraw.lib c:\dx6\lib\dsound.lib c:\dx6\lib\dinput.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Btw I''m using directx6 (following Tricks book)
I don''t think I need the dsound and dinput but you can''t be too careful

Share this post

Link to post
Share on other sites
Kaezin    158
Wow thank you so much! That solved everything! I thought that Deej just put the * there so he didn't have to repeat himself =D It compiled flawlessly (even without the warnings I usually get hehe), wow I really can't thank you enough, to the both of you guys.

Fixed many typos in my excitedness hehe

Edited by - Kaezin on August 23, 2001 11:03:40 PM

Share this post

Link to post
Share on other sites