Skip to main content
gamedev.net
🔒 Locked

Error with Game Engine

Started by deathknight2005 6 replies 1.3k views
Original Post
deathknight2005
deathknight2005
I have recently bought a book called "Ultimate Game Programming with DirectX" It has been a good book, but unfortunately some of the code is not working with my compiler. I am using Visual C++ 2005 Express, the book uses Visual C++ 2003. In the part that I am having trouble with, the book told me to create a project and then to create main.h and main.cpp (It gave me the code). Then It told me to go to File->Add->New Project and it told me to clike it and create a new project called "StrandedEngine",I changed the configuration on StrandedEngine to Static Library (.lib) file. Then I added a few source and header files to StrandedEngine and wrote in the code. The problem I am having lies in main.h, I am meant to include a file from StrandedEngine in main.h, except main.h is a part of the GameProject project, they are both in the same solution though. The book told me to write the include file like this: #include "StrandedEngine/engine.h" Unfortunately it is giving me this error when I try to debug it: fatal error C1083: Cannot open include file: 'StrandedEngine/engine.h': No such file or directory Here is the code for main.h:

#ifndef _UGP_MAIN_H_
#define _UGP_MAIN_H_


#include"StrandedEngine/engine.h"
#pragma comment(lib, "lib/StrandedEngine.lib")

#define WINDOW_CLASS    "StrandedGame"
#define WINDOW_NAME     "Stranded"
#define WIN_WIDTH       800
#define WIN_HEIGHT      600
#define FULLSCREEN      1

// Function Prototypes...
bool InitializeEngine();
void ShutdownEngine();

// Main game functions.
bool GameInitialize();
void GameLoop();
void GameShutdown();

#endif

I have no idea what the problem is, maybe it is because I am using VC++ 2005 instead of 2003?
Dunge
Dunge
#include"StrandedEngine/engine.h"
#pragma comment(lib, "lib/StrandedEngine.lib")

I guess you need to put the StrandedEngine project folder and the lib folder inside the GameProject project folder. I never used the engine though so I dunno.
deathknight2005
deathknight2005
Strangely enough, I do not have a .lib file in my project! I did whatever the book said, I changedthe one project to static library(.lib) but for some reason I do not have a lib file in the folder. I have never worked with .lib files before and I have no idea why the book's project has a .lib file and mine doesn't. If anybody knows anything about these files could you tell me how I could get a .lib file in my project(named after the second project I made, StrandedEngine.lib.
smitty1276
smitty1276
To get the lib file you have to build your project, which you can't do because you have your include paths wrong. Whichever folder has the StrandedEngine folder in it (which should in turn contain the .h file) should be in your include path.
deathknight2005
deathknight2005
Thank you, it works now! For some strange reason, I needed to write out the whole include path, starting all the way from C:/!
smitty1276
smitty1276
You don't want to put the entire include path in your source code. You need to set the include paths for your project... go under Project->Properties->Configurations->C/C++->Include Paths and add the path of the folder containing the engine directory. That menu "trail" I just gave is an approximation, by the way. I don't have it open in front of me.
_goat
_goat
smitty has it right.

Also: Just from that brief glance at the code from the book - I would be rather careful, as #defines for "values" are usually a sign of bad C++ code-wide. That, and it uses a bunch of functions which appear to require state information, even though they don't take any parameters, or nor do they belong to a class. Just a heads up. If you're really lucky, in the future you can post part of your engine code to the forums under "help this code", and hope to god Zahlman decides to undertake it as a project. :D

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.