• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Juliean

Game engine lib problems

11 posts in this topic

Hello,

 

so I've come to decide that its time to split up the code of my engine an the sample game I'm building with it. For now I've just had one solution, and one project, with game and engine code simply split up by different folders in Visual Studio. So I've tried to split it up in two different projects to begin with. I've tried to compile the engine as a static libary and link the game against it. This however doesn't seem to work very well, since I'm encountering a serious of errors when buildung the game:

 

1>c:\work\repo\editor\Rect.h(22): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\work\repo\editor\Rect.h(22): error C2143: syntax error : missing ',' before '&'
1>c:\work\repo\editor\Rect.h(24): error C2065: 'vPoint' : undeclared identifier
1>c:\work\repo\editor\Rect.h(24): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\work\repo\editor\Rect.h(25): error C2065: 'vPoint' : undeclared identifier
1>c:\work\repo\editor\Rect.h(25): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(28): error C2039: 'acosf' : is not a member of '`global namespace''

This is e.g. Rect.h from my engines project:

 

 

#pragma once
#include <Windows.h>
#include "Vector.h"

struct Rect
{
public:
    Rect(void)
    {
        x = 0, y = 0, width = 0, height = 0;
    }
    Rect(int x, int y, int width, int height)
    {
        this->x = x, this->y = y, this->width = width, this->height = height;
    }
    
    void Set(int x, int y, int width, int height)
    {
        this->x = x, this->y = y, this->width = width, this->height = height;
    }

    bool Inside(const Vector2& vPoint) const
    {
        int distanceX = vPoint.x - x;
        int distanceY = vPoint.y - y;
        return distanceX >= 0 && distanceX <= width && distanceY >= 0 && distanceY <= height;
    }

    Rect Merge(const Rect& rect) const
    {
        int x = max(this->x, rect.x);
        int y = max(this->y, rect.y);
        int x2 = min(this->x+this->width, rect.x+rect.width);
        int y2 = min(this->y+this->height, rect.y+rect.height);
        return Rect(x, y, x2-x, y2-y);
    }

    RECT GetWinRect(void) const
    {
        RECT r = {x, y, width, height};
        return r;
    }

    int x, y, width, height;
};

With "Vector2", my personal integer vector class, obviously not being defined here. Although everything is working fine when compiling the engine to the lib (well, almost, I'll get to that later).

 

So do you know what could cause this error? Obviously, if you look at the last error message, not only my classes causes this but also something in the "cmath" header.

I've added "C:\Work\Repo\Editor" where all my .cpp and .h are to include directories for the Game, as well as linked against the .lib file currently located in "C:\Work\Repo\Release\". Anything else that I have to do in order to work with static libs?

 

Aside from that, I've also noticed that the .lib file generated is huge - 55 Mb, while the application previously built is only about 150 kb in size. Any possible reasons for that, or did I do something wrong? Maybe this is related to my errors...

0

Share this post


Link to post
Share on other sites

cmath puts the maths functions into namespace std so you want to qualify it as std::acosf if it is in a header (you could use using namespace std; in a cpp file).

 

Is the error in vector.h? Has it got the definition of Vector2 in it? Is there a semicolon at the end of the last class declaration in that file? Might be better posting vector.h anyway...

1

Share this post


Link to post
Share on other sites

Point is, I never made use of "acosf" or anything like those - there is actual dozens of errors messages regarding this libary. This is Vector.h:

#pragma once

class Vector2
{
public:
    Vector2(void);
    Vector2(int x, int y);
    ~Vector2(void);
    
    double length(void) const;
    Vector2& absolute(void);

    Vector2 operator-(const Vector2 &v) const;
    Vector2 operator/(int iDevisor) const;

    Vector2& operator+=(const Vector2 &v);
    Vector2& operator-=(const Vector2 &v);

    Vector2& operator/=(int iDevisor);

    int x,y;

};
 

And that is Vector.cpp:

 

 

#include "Vector.h"
#include <math.h>

#pragma region vector2

Vector2::Vector2(void) : x(0), y(0)
{
}

Vector2::Vector2(int x, int y) : x(x), y(y)
{
}

Vector2::~Vector2(void)
{
}

double Vector2::length(void) const
{
    return sqrt((double)(x*x+y*y));
}

Vector2& Vector2::absolute(void)
{
    x = abs(x);
    y = abs(y);
    return *this;
}

Vector2& Vector2::operator/=(int iDevisor)
{
    x/=iDevisor;
    y/=iDevisor;
    return *this;
}

Vector2 Vector2::operator-(const Vector2 &v) const
{
    return Vector2(x-v.x, y-v.y);
}

Vector2 Vector2::operator/(int iDevisor) const
{
    return Vector2(x/iDevisor, y/iDevisor);
}

Vector2 & Vector2::operator-=(const Vector2 &v)
{
    x -= v.x;
    y -= v.y;
    return *this;
}

Vector2 & Vector2::operator+=(const Vector2 &v)
{
    x += v.x;
    y += v.y;
    return *this;
}

#pragma endregion
 

Both are included through "Math.h"

 

#pragma once
#include "Vector.h"
#include "Rect.h"

#define DEGTORAD(degree) ((D3DX_PI / 180.0f) * (degree))

 

Before splitting game and engine, everything compiled just fine, no error whatsoever. See anything suspicisous here?

0

Share this post


Link to post
Share on other sites

Yeah, that did the job, thanks! But now there is one last thing. Without further work, I get this error

fatal error C1083: Cannot open include file: 'd3dx9.h': No such file or directory

on every occasion where I included d3dx9.h in my engine. Obviously solvable by also adding the dx-include directory to my games include-dir list, but this shouldn't be necessary... should it? If no, what can I do to avoid that?

 

Also, I've still got the issue with the way to big .lib - in debug it is around 23 MB. Any advice on that, too?

0

Share this post


Link to post
Share on other sites

Is it in angle brackets? Otherwise you may have to add the sdk path to your additional include directories.

 

Don't worry about the lib size, when it is linked into your exe it strips out anything not required.

1

Share this post


Link to post
Share on other sites

Yes, indeed it is:

#pragma once
#include <d3dx9.h>
#include <d3d9.h>

Oddly enough, it only has problems finding the d3dx9.h - d3d9 doesn't throw an error, even if I swap their position, and although both are located in the same folder. Some idea or do I really have to add the path to the games additional include directories? Wouldn't that be really weird, say for example if I was using more than just the directx lib to always have to add all needed directories to every game I wanted to use the engine?

0

Share this post


Link to post
Share on other sites

Are you sure it is looking in the folder you think it is? Have you got more than 1 direct X SDK install? Try searching your hard drive for all occurences of d3d9.h and see if they all have a d3dx9.h in there too. That's all I can think of...

1

Share this post


Link to post
Share on other sites

Well, I didn't install more than one DirectX SDK, but since I'm on windows 8 (on that PC), there is one Folder "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin" which has only a d3d9.h but no d3d9x.h and, as well as one "C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86" folder, same with only the d3d9.h. Could this be the reason? I added "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include", the path to my DirectX sdk, to the additional include paths of my engine...

Edited by The King2
0

Share this post


Link to post
Share on other sites

Yes, that will be the problem. Looks like the Windows SDK path is being used instead of the DirectX SDK path. What definitions do you need d3dx9.h for anyway?

2

Share this post


Link to post
Share on other sites

What definitions do you need d3dx9.h for anyway?

 

I'm using the D3DXSprite, D3DXMATRIX, etc... , if thats what you are asking for? Appearantly, I'd additionally need to tell the linker to link to the d3d9.lib, as well as the d3dx9 and some other libs. Gosh, I hate Windows 8 :/

 

Well now granted I did, since its OK for now (going to test if this persists on Windows 7 tomorrow) c+p all the include and link stuff from my engine project. I still get some unresolved symbol errors. Well, at least we are partially in the territory of the game project now:

 

1>LightAttributeCtrl.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall GuiObject::OnKeyStroke(char)" (?OnKeyStroke@GuiObject@@UAEXD@Z)
1>MaterialAttributeCtrl.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall GuiObject::OnKeyStroke(char)" (?OnKeyStroke@GuiObject@@UAEXD@Z)
1>ObjectAttributeCtrl.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall GuiObject::OnKeyStroke(char)" (?OnKeyStroke@GuiObject@@UAEXD@Z)

Whereas the function is declared as :

 

class GuiObject {  
...
  virtual void OnKeyStroke(TCHAR key);
...
}

and defined as

 

void GuiObject::OnKeyStroke(TCHAR key)
{
}

I won't post the whole GuiObject.h code since it is really huge and probably contains nothing to help solve the problem. <Windows.h> is included in the header, however, so is GuiObject.h to each of the Controller-classes throwing the error. Some ideas why it could be crashing on this very function? Ouch, silly me, forgot to set the new project to unicode. Hrmpf. Could slap myself for this. Anyway, for now it is working, except this one very annoying need-to-include-stuff-thats-already-included-in-my-engine - thing. Out of interest, how does other engines handle this? Did the windows 8 SKD completely drop the d3dx9-stuff or is there any other way to correctly include it?

Edited by The King2
0

Share this post


Link to post
Share on other sites

Out of interest, how does other engines handle this?

 

i was going to say, you seem to be doing it the hard way.

 

don't make the game library a separate project. just make it an existing .cpp and .h file you add to your game project.    

 

IE just another module.    

 

only difference, this module has generic reusable code and is include in many different game projects, instead of being game specific and used in just one project.. 

 

always set your compiler options first when you start a new project. I keep a 3 page list of all the correct settings for a release build of any game. this avoids stuff like wrong char type. that one bites me a lot too, hence the lists, way too much to memorize.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0