Home » Community » Forums » For Beginners » Beginner: Error message when compiling first program
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Beginner: Error message when compiling first program
Post New Topic  Post Reply 
I just bought Tricks of the Windows Game Programming Gurus. I am trying to compile the first program(source code for freakout) and everytime i try, i get these two error messages:
"error C2146: syntax error : missing ';' before identifier 'lpdd"
and
"fatal error C1004: unexpected end of file found"

Does anyone know what I can do to fix this and have it compile?

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Sounds like you have missed a ; somewhere.
If you're using VC++ then the error is most likely on the line above the line idicated as wrong.

 User Rating: 1030   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Are those two the only error messages you get?

I'm asking, because it seems to me like you are declaring an IDirectDraw pointer (called 'lpdd') where the error occurs.
The errors you describe often occur when the type in a declaration is an unknown identifier, though if that was the case, then you should have gotten an error saying something like "Unknown identifier LPDIRECTDRAW".

Have you included all the correct headers and made sure that the correct versions of them are being included?
From the error messages I guess you are using Microsoft Visual C++. Make sure that the list of search paths for include files have the DirectX directory before any directory that came 'preconfigured' with the compiler. The reason this is necessary is because MSVC++ comes with an early version of DirectX (verison 3 or 5 or something) and the compiler will use whatever header it finds first (with a matching name).

Edited by - Dactylos on September 16, 2001 10:08:30 AM

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Make sure that you are linking to the dx libs and includes as well as having the #include at the top of your file.

Eric Wright o0Programmer0o

AcidRain Productions

 User Rating: 1045   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

There are 3 ways to link with the libs

a) Add them to the project
b) Include them in the linker settings of your compiler
c) use
#pragma comment(lib, "libname.lib")
in your source code for each lib you want to link with

DeathWish

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Seeing as how no one thought to inform you of what libs you need...I'll do that.

If the sample app uses direct sound: Link dsound.lib
If the sample app uses direct draw : Link ddraw.lib
If the sample app uses direct input: Link dinput.lib

For all of the above you must also: Link dxguid.lib

 User Rating: 1041   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I have the book, good book, and freakout is a great example at designing games.
I think your problem could have 2 causes:
1) A syntax error. You didn't specified if you entered the breakout.cpp file via the keyboard ( I mean to type in the whole file ).To eliminate that cause of error, why don't you try to create a blank breakout.cpp file in the project then copy and paste the whole breakout.cpp file content from the CDROM ( Don't forget to change that file properties by right clicking on the icon and changing from read only to archive )
By doing that you'll be sure that at least the syntax is correct and that the only remaining cause of error is project or compiler related like missing file in the project, or wrong header or library path in the compiler options.
I hope this helps



 User Rating: 1015    Report this Post to a Moderator | Link

Hi,

I compiled freakout and according to the explainations in the book it requires a lot of libraries, some mentioned in the book are not even on my DX8 SDK version ( like directsound 3d ).
But it compiled OK with the following libraries included in the project:
blackbox.cpp
blackbox.h
ddraw.h
ddraw.lib
freakout.cpp
winmm.lib

And don't forget in your VisualC compiler to set the the complete path for the DX SDK headers ( .h ) files and libraries in the Following menus:
Tools->options->directories->Include files and library files.
As an example, my DX8 SDK lib has the following path:
( I uses DX8 SDK , you directories names can vary with the version )
D:\Dxvcsdk\include

And , very important after you entered these 2 paths, make them the first paths in the list by selecting them and using the up arrow located just below" Show directories for"

I would highly recommend you to compile an easier example like the one ( I forgot the chapter number is it 7 ?) that plots some random pixels on the screen.
In order to compile it you only need to include the following files in your project:
YourExampleFile.cpp
ddraw.h
ddraw.lib
winmm.lib ( In the VisualC++ libraries folder ).

I hope this helps, and I understand it is REALLY FRUSTRATING to screw-up the first compiled DirectX program ( believe me )

I sincerely hope this helps

Jacques




 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may not post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: