• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# 02.07 - The Readiness Test

215 replies to this topic

### #1Teej  GDNet+

Posted 20 April 2001 - 04:05 AM

Oh Goody, Code Time! Alright recruits, we’re about to test your compiling and linking skills. I’ve added a zipfile called BASECODE1 on my website that I’d like you to download now (don’t unzip it yet though!). The zipfile contains the following files:
• Globals.h – the main header file for the game template
• WinBase.cpp – the windows application overhead we’ve discussed
• InitTerm.cpp – the initialization/shutdown functions
• GameMain.cpp – where the game code goes
• Utils.h – prototypes for our helper functions
• Utils.cpp – the helper functions themselves
• Resource.bmp – a sample bitmap
• Sample.wav – a sample WAV file
• DDRAW.H
• DINPUT.H
• DSOUND.H
…which contains prototypes for the DirectDraw, DirectInput and DirectSound components we’re using. The actual components (the DirectX runtimes) are called:
• DDRAW.DLL
• DINPUT.DLL
• DSOUND.DLL
…which are the files that everyone has for playing DirectX games with. Finally, we have library files that connect code using DirectX components:
• DDRAW.LIB
• DINPUT.LIB
• DSOUND.LIB
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: C:\DXVCSDK\LIB\*.lib 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: SOMELIB.LIB OTHERLIB.LIB YETMORE.LIB… (Whatever their names actually are, who cares). Now it should be: C:\DXVCSDK\LIB\*.lib WINMM.LIB SOMELIB.LIB OTHERLIB.LIB… Got it? Mission Control… Now for the big moment. Build the project (by hitting F7), and pray that you see ‘0 errors, 0 warnings ’ when it’s done. If you are having problems, first realize that the build process involves two stages, compiling and linking, both with their own types of errors. For instance, the link process won’t even begin if there were errors in the compile stage. Either you saw ‘Linking…’ in the output window or you didn’t. If you are getting complaints like:
Compiling...
GameMain.cpp
c:\gdn\basecode\globals.h(87) : error C2146: syntax error : missing ';' before identifier 'lpDD'
c:\gdn\basecode\globals.h(87) : error C2501: 'LPDIRECTDRAW7' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(87) : error C2501: 'lpDD' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(88) : error C2146: syntax error : missing ';' before identifier 'lpDDSPrimary'
c:\gdn\basecode\globals.h(88) : error C2501: 'LPDIRECTDRAWSURFACE7' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(88) : error C2501: 'lpDDSPrimary' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(89) : error C2146: syntax error : missing ';' before identifier 'lpDDSBack'
c:\gdn\basecode\globals.h(89) : error C2501: 'LPDIRECTDRAWSURFACE7' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(89) : error C2501: 'lpDDSBack' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(90) : error C2146: syntax error : missing ';' before identifier 'lpDDSRes'
c:\gdn\basecode\globals.h(90) : error C2501: 'LPDIRECTDRAWSURFACE7' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(90) : error C2501: 'lpDDSRes' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(94) : error C2146: syntax error : missing ';' before identifier 'lpDI'
c:\gdn\basecode\globals.h(94) : error C2501: 'LPDIRECTINPUT7' : missing storage-class or type specifiers

(…on and on…) then you probably need to make sure that you’re pointing the IDE to the DirectX header files (look in Tools|Options|Directories ). If you have other compile errors, try to get ahold of me (teej@gdnmail.net or 70816765 on ICQ) or post a reply to this article with your questions. As for the linking, well, that’s primarily the job of the LIB list we prepared under Project|Settings|Link. Here’s an example of having it entered incorrectly:
Linking...
InitTerm.obj : error LNK2001: unresolved external symbol _DirectDrawCreateEx@16
InitTerm.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7
InitTerm.obj : error LNK2001: unresolved external symbol _c_dfDIKeyboard
InitTerm.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboard
InitTerm.obj : error LNK2001: unresolved external symbol _IID_IDirectInputDevice7A
InitTerm.obj : error LNK2001: unresolved external symbol _DirectInputCreateEx@20
InitTerm.obj : error LNK2001: unresolved external symbol _IID_IDirectInput7A
InitTerm.obj : error LNK2001: unresolved external symbol _DirectSoundCreate@12
Debug/basecode.exe : fatal error LNK1120: 8 unresolved externals

basecode.exe - 9 error(s), 0 warning(s)

As you can see, since the libraries weren’t included properly, the poor linker was lost when it came to including these symbols. Once again, let us know if you’re stumped. NOTE: When we added the libraries in for the linker, you may have noticed on the left side of the screen that there was a box that had ‘Settings for: Win32 Debug ’. Keep in mind that these libraries that you’re adding are only valid when in Debug mode. You can either change this box to read ‘All Configurations ’ before entering your libraries, or enter them a second time when in Release mode. So Far So Good… If you managed to reach the finish line, ‘0 errors, 0 warnings ’, run the program (CTRL-F5) and hopefully you’ll be rewarded with some text on the screen. The space bar will cause a sound to play, and ESCAPE will exit the program. If you aren’t here yet, don’t bother continuing in the forum! That’s why this is called the ‘Readiness Test’… if you can’t get this stuff to run you need to let us know so that we can help rectify the situation. What about the program itself? On the surface, it doesn’t seem to do much. In fact, it uses DirectDraw, DirectInput and DirectSound in proper form (initialization, use and shutdown), so it’s a good learning example. In later articles we will be using and building on this framework, so it’s a good idea to get your DirectX online documentation ready and try going through the code. Of course, the documentation provides excellent introductory material on each of these components, and if you take the time to read some of it you’ll be ahead of the game. The Ladder series was designed to represent ‘prerequisite knowledge’. You know have everything you need to start on your path to enlightenment:
• An introduction to game development
• A basic windows application framework
• C language resources
• A quick overview of some of the basic tools required
• Some insight into how a game might be written
• Information on resolutions, colors and pixel plotting
• The role of DirectX in our games
• A first run with some game template code
Congratulations… You have your compiler/linker in order, the DirectX runtimes and SDK installed, the online documentation at your fingertips, and some template code that sits before you like an open book with blank pages – ready to be filled in with the knowledge and practice that is the rite of passage for any apprentice. Get ready folks, because next up is the proverbial ‘Square One’. See you there. Questions? Comments? Can’t get the damned code to build? Reply to this article – help is on the way! Edited by - teej on April 20, 2001 11:10:00 AM

### #2Fighterdude  Members

Posted 20 April 2001 - 10:10 AM

i can build the program fine errors 0 and warnings 0
but when i try to run it says DD_init faild.|-7

Fighterdude(A Baldurs Gate Fan)

### #3Lord Maz  Banned

Posted 20 April 2001 - 10:26 AM

I can''t get my modem to download those directx files.. the connection is too slow, and it stoppes after a while
If anyone could upload the files on a better server (or buy me a better modem!), I would be gratefull!

-Lord Maz-

### #4Qunu  Members

Posted 20 April 2001 - 11:06 AM

Fighterdude: make sure you have the resource.bmp and sample.wav files in the same directory as your executable.

### #5Anonymous Poster_Anonymous Poster_*  Guests

Posted 20 April 2001 - 11:07 AM

Fighterdude: make sure you have the resource.bmp and sample.wav files in the same directory as your executable.

### #6Crox_guldtand  Members

Posted 20 April 2001 - 11:29 AM

Hey Fighter dude!

You haven´t got the "resource.bmp" file in the same catalog/dir.
as the other files.
Just put it there and it´ll work fine.

### #7Fighterdude  Members

Posted 20 April 2001 - 02:27 PM

i have them all in the same directory
and it still does the same thing.

Fighterdude(A Baldurs Gate Fan)

### #8Fighterdude  Members

Posted 20 April 2001 - 02:30 PM

Forget the last post i just got what you were saying and it works now Thanks Guys

Fighterdude(A Baldurs Gate Fan)

### #9Fighterdude  Members

Posted 20 April 2001 - 03:01 PM

Just wonderin Teej is the next artical the C LANGUEGE or you gonna post a new one? Great job Teej i realy like it!

Fighterdude(A Baldurs Gate Fan)now that''s a good Game

### #10Fighterdude  Members

Posted 20 April 2001 - 03:01 PM

Just wonderin Teej is the next artical the C LANGUEGE or you gonna post a new one? Great job Teej i realy like it!

Fighterdude(A Baldurs Gate Fan)now that''s a good Game

### #11Fighterdude  Members

Posted 20 April 2001 - 03:03 PM

sorry for Multi-Post

Fighterdude(A Baldurs Gate Fan)

### #12Fighterdude  Members

Posted 20 April 2001 - 05:14 PM

do i have to get the online version or can i get it in word format?

Fighterdude(A Baldurs Gate Fan)

### #13Fighterdude  Members

Posted 20 April 2001 - 05:16 PM

The Docs i mean!

### #14Mucman  Members

Posted 20 April 2001 - 06:59 PM

Well I''ll be darned! It worked at the first build! Should I be surprised

"You won''t get wise with the sleep still in your eyes." - Neil Peart

### #15Thalion  Members

Posted 21 April 2001 - 07:59 AM

Why do I get this error?

Compiling...
WinBase.cpp
InitTerm.cpp
Utils.cpp
GameMain.cpp
LINK : fatal error LNK1104: cannot open file "C:\program.obj"

### #16Higgenkreuz  Members

Posted 21 April 2001 - 08:05 AM

I get the following messages while I try to compile:
d:\dxvcsdk\lib\ddraw.lib : fatal error LNK1106: invalid file or disk full: cannot seek to 0x389bc793

I checked the path to my lib file, it is fine, also, I still have some 150MB of free space on my HD.

Any ideas?

### #17Scogs  Members

Posted 21 April 2001 - 11:42 AM

Thalion,

I had the same error as you, so I deleted the project, re-installed the SDK, followed Teej''s instructions again and it all worked fine. Try it, you never know it might work?

Scogster.

PS. Teej your a top man.

Posted 21 April 2001 - 02:42 PM

i cant find the site if you can send me the adress or the files to my email i will apreciate it.

you are doing a good job

Edited by - thadarkangel on April 21, 2001 9:44:42 PM

### #19Mucman  Members

Posted 21 April 2001 - 04:59 PM

As for readiness, are we expected to know and understand what the heck all those utility functions do? Or know exactly how the implementation works?

"You won''t get wise with the sleep still in your eyes." - Neil Peart

### #20Piotyr  Members

Posted 21 April 2001 - 05:25 PM

At this point, just think of it as a black box "template" to program your game code in. The only function you need to worry about if you use the template is really the Game_Main function, and perhaps a bit about the shutdown and/or init functions. Don''t get overwhelmed. If you''re completely lost, there are some good tutorials around on DirectX to learn more than what Teej overviewed thus far, and he might even go more in-depth at a later time.