Archived

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

Sir_Spritely

RE:Tricks of the Windows Game Programming Gurus

Recommended Posts

Hi, I got this book on recommendation and the first program in the book will not compile. I am getting 2 errors, one from one cpp file and another from the other cpp file. Both saying Unexpected end of file reached unable to locate precompiled header file. I have even tried commenting out the include files and I get the same error. I have as far as I am aware installed the DirectX correctly but I cannot get rid of these errors. If anyone has used the book and knows how to correct the errors or anyone knows why the problem may be happening please let me know as I just think I''ve wasted £37

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Sometimes when copying files from CD roms one has to adjust the attributes - change to archive instead of read only. Sometimes the eof doesn''t register - just a black box. If you see that at the end of each file, you might want to delete the last line in the file and add a couple of newlines of your own then save and try again.

Share this post


Link to post
Share on other sites
Go into project the settings and select ''No precompiled header'' (or something similar).

These examples are small enough not to take a build hit without PCH files.

IMHO: Why did you spend 37 pounds? Just to get the code off the disk? In that case you have wasted your money. All the code on the disk is available (in other forms) on the net. A little searching will find them. If you bought it for the reference material then you haven''t wasted your money. There is more to game writting than just code.


D.V.

Share this post


Link to post
Share on other sites
Whenever you ask for help, provide as much information as possible. Those compiler error messages are very useful to someone who knows the compiler (or knows where to look them up). I'd advise you post the text of the error messages in full. Something along the lines of:

"D:\Microsoft Visual Studio\file.cpp(33): error C2307: Unknown variable 'foo'"
"D:\Microsoft Visual Studio\file.cpp(33): warning C4786: Variable name exceeds 255 characters; will be
truncated in Debug output"

I'll check back.

Edit: line truncation (how ironic)



I wanna work for Microsoft!

Edited by - Oluseyi on November 5, 2001 12:58:16 PM

Share this post


Link to post
Share on other sites
Unless I am mistaken, you are using Microsoft Visual C++. Am I right?
You are getting that error because your Visual C++ project is set to use a precompiled header file, but you are not including the correct header file in your source.
Usually Visual C++ bases the precompiled header file on stdafx.h. If you do not include stdafx.h in your source, you will get the error you are getting.
Precompiled headers can be a good thing. They can cut down re-compile time considerably. Take a look at the online help or let me know if you want some more information on how to get them to work.
If you just want to turn off precompiled headers so you can compile the programs from the book go to the "C/C++" tab of the project settings dialog. Select the "Precompiled Headers" category from the drop down list. Select "Not using precompiled headers" and save the project settings.

Share this post


Link to post
Share on other sites
Hi,

It''s always the little things, I had missed off the stdAfx.h in the include section, I am a newbie .

However when compiling I am still having problems, I now have the following errors: -

Blackbox.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw4
Blackbox.obj : error LNK2001: unresolved external symbol _DirectDrawCreate@12
Debug/chap1.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

chap1.exe - 3 error(s), 0 warning(s)

I have included the Ddraw.h in the project area and included it in the program. I am pretty stumped at the moment, any suggestions? I am using MS VC++6 btw.

Paul.

Share this post


Link to post
Share on other sites
Hey,

I got it down to 1 error now I had not added the ddraw.lib to the path.

I am now getting this 1 bastard error: -

Linking...
LINK : fatal error LNK1104: cannot open file "odbccp32.libn"
Error executing link.exe.

Anyone???

Paul.

Share this post


Link to post
Share on other sites
You messed with the libraries to add to the project. ".libn" is not a valid library file extension (and there''s unlikely to be any file with that extension). It was probably a small typo when you were adding ddraw.lib to your project, so go back and check the entire list.



I wanna work for Microsoft!

Share this post


Link to post
Share on other sites
Hi,

Yeah I sorted that however I was still getting an error so I have decided to start from scratch again.

What I am not sure of is setting up the link to files and the actual compiler and project area so I have all the possible DirectX lib and header files I will need. Once I know this then realistically the program should work I think! It is Chapter 1 of the Tricks of the Windows Game Progamming Guru''s by Andre Lamothe - the breakout style game.

I also think I need to install the most current DirectX, v8 i believe it is. Where can I get this from and is it just a case of the usual double click the setup file to install.

Some of things I have been doing as well is putting the directX header and lib files in the actual project directory and then adding them to the header files. Also to the linker list.

Also do I need to set up any paths so the compiler knows where 2 find the DirectX files. I have used seperate header files, ones I have coded myself but DirectX just doesn''t seem to be working the usual way

Help appreciated!

Paul.

Share this post


Link to post
Share on other sites
don''t move the dx source/headers to your directory. you can simply make a reference to the headers by adding the path in Tools/Options/Directories so that it looks at the dx headers.

Share this post


Link to post
Share on other sites
Big Thanks to everyone that helped, problem solved - game now loads and now I can press on .

C++ should come with a better book than that Intro to Vis C++ standard ed. Tells ya nothing.

Being lame would be putting cracked by Spritey on the freakout game in the TOTWGPG book LOL! - I have Lamer tendancies I would say though

Share this post


Link to post
Share on other sites
There are tons of good c++ books. My personal favourite is "The C++ Programming Language. Special Edition" by Bjarne Stroustrup. Although it might not be the best solution for a newbie it''s an excelent reference.

------------------------------------------------------------
"To a computer, chaos is just another kind of order."

Share this post


Link to post
Share on other sites