Advertisement

I need Help

Started by December 10, 2004 11:14 AM
7 comments, last by da_grat1 19 years, 11 months ago
I download a game from this website, but i cannot run the source code of the game. The title of the game is "Eight_Queens".. Can anyone try to download the game and tell me whether the source code is working or not.. The game can be found in this website,in the NEHE download section and choose the Alphabeth E.. thanks...
Litte information about what does not work would be appreciated ;)
Advertisement
I think this source code is a demo game but i cannot run it. There are 4 .CPP files inside the source code folder.. when i open the first cpp file "Dinput.cpp", there are 3 errors come out.
SampleGL\Eight Queens\Dinput.cpp(10) : error C2146: syntax error : missing ';' before identifier 'g_DI'
SampleGL\Eight Queens\Dinput.cpp(10) : fatal error C1004: unexpected end of file found
SampleGL\Eight Queens\Dinput.cpp(10) : error C2501: 'LPDIRECTINPUT8' : missing storage-class or type specifiers

I cannot detect the first error which is missing ';'. but the coding before it has ';'. I really cannot find the error. But when I open the "game.cpp" It detects two errors..
samplegl\eight queens\game.cpp(11) : error C2600: 'Game::Game' : cannot define a compiler-generated special member function (must be declared in the class first)
samplegl\eight queens\game.cpp(15) : error C2600: 'Game::~Game' : cannot define a compiler-generated special member function (must be declared in the class first)..

All the .cpp files got error. Maybe there are steps or methods to run the .cpp files.. what i mean is step by step eg..open the "A.cpp" first then open "C.cpp" or something like open the .dsw first...But i don't how..

Sorry for my bad English :)
It says the ; is missing because it doesn't understand what 'g_DI' means. You obviously do not have all the files required to compile the project. I'm not sure where g_DI comes from, I have a feeling its from the DirectX SDK.. could be wrong. Anyway, the problem is you are missing required files that are external to the project.
Yes, those errors are created because you did not inlcude all the needed header files for DirectX. Also make sure you include all the libraries.
First, Start over.

Unpack the zip into a new directory.
Double click on Queens.dsw
When it loads, make sure you're in 'Release' mode.
Click 'Rebuild All' in VC6 or 'Rebuild Solution' in VC7

*Here's the errors I got on the first pass:

Compiling...
Text.cpp

1.)Queens.cpp
c:\program files\microsoft visual studio .net 2003\vc7\platformsdk\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800

2.)Game.cpp
c:\CALCULATORS\8queens\orig\Eight Queens\Game.cpp(11) : error C2600: 'Game::Game' : cannot define a compiler-generated special member function (must be declared in the class first)
c:\CALCULATORS\8queens\orig\Eight Queens\Game.cpp(15) : error C2600: 'Game::~Game' : cannot define a compiler-generated special member function (must be declared in the class first)

3.)Dinput.cpp
c:\program files\microsoft visual studio .net 2003\vc7\platformsdk\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800

Build log was saved at "file://c:\Calculators\8queens\orig\Eight Queens\Debug\BuildLog.htm"
queens - 2 error(s), 0 warning(s)

*Here's what i did to fix the errors:

*Error-1 - don't do anything just let it default.
*Error-2 - declare Game(); and ~Game(); constructor and destructor inside the class in Game.h

class Game
{
private:
int board[8][8]; //1 means filled, 0 empty
int numqueens;

public:
Game(); ////////// add this
~Game(); ////////// add this
void NewGame();
int PlaceQueen(int x, int y);
int CheckRow(int row);
int CheckColumn(int column);
int CheckDiagonal(int x, int y);
int CheckForQueen(int x, int y);
int GameStatus();
};

*Error-3 - don't do anything, just let it default.

And the result:

---------------------- Done ----------------------

Rebuild All: 1 succeeded, 0 failed, 0 skipped


You need to have at least the directx8 sdk/platform sdk installed to compile this.
Your other error about 'g_DI etc. probably has to do with the above.
The latest DirectX sdk is a free (but large) download from msdn.microsoft.com.
You can also order a CD if you find the download somewhat 'ungainly'.
Also be sure you have the Platform SDK installed, it's rather a must.

Another thing you might check is the latest service-pack for VC6 if that's the compiler you're using, I believe the last one is still available for download, but I'm not sure.

Also remember I told you in your last thread you could get VC7 free, that will cure a lot of problems in itself.
But you'll still need to get the Platform SDK and DirectX SDK. You also won't have an IDE to compile from.

The *easiest* way to solve a lot of your compilation problems is to just order VC7 Standard since you'll get the Platform SDK and DirectX and be up to date with a 'complient' compiler without having to mix and match service packs and SDKs.

It's less than a hundred bucks and will save you a lot of trouble and frustration both now and in the future.
Advertisement

How to include all the libraries? Do mean to go to the project setting and add the "glu32.lib opengl32.lib glaux.lib" libraries...?
>How to include all the libraries?
>Do mean to go to the project setting and add the "glu32.lib opengl32.lib glaux.lib" libraries...?

If you invoke VC by double clcking on a project or workplace file (i.e. Queens.dsw), the project will load with all of the compiler and linker settings intact, just as the original author intended.

You would, indeed, need to add these things (libs) if you were coding an OpenGL app from scratch and personally, I would use compiler 'pragmas' to tell the linker which libraries to search for any binary resolutions that may be needed.

Of course, pragmas are compiler-dependent so the source wouldn't necessarily port to, say, Dev-c or lcc or Borland but it does make it easier on you since you can see right from your source file if the linker knows to search the libs needed by your program (rather than having to set these in a configuration dialog for your linker).

Here's some examples of including libs with pragmas:

//headers for forward-declarations of functions you'll be using:
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
#include <mmsystem.h>

//pragmas tell linker to link with these libs:
#pragma comment(lib,"opengl32.lib")
#pragma comment(lib,"glu32.lib")
#pragma comment(lib,"glaux.lib")
#pragma comment(lib,"winmm.lib")

You won't need to do any project-settings for link libraries if you use pragmas for any non-default libs you use.

Like I said, this works for Visual C++, compilers from other vendors have their own set of pragmas.

If, however, you don't *have* said libraries available on your drive (as may be the case with your DirectX problems), then you need to download the SDKs, as mentioned in my previous post, and install these libraries and headers to your system.
Thanks a lot.. It works after i tried your methods and after i installed the directx 8 sdk... Yeah...

You are really a helpful person... ^_^

This topic is closed to new replies.

Advertisement