Singleton Unresolved External in Other Library

Started by
1 comment, last by Whorse 12 years, 6 months ago
Hey there everyone, busy implementing a globals class with all the singletons I need in my "Engine" project. I had handled this differently prior, but felt it needed redoing. My issue now is that my "Game" project links to the engine library, however when I attempt to compile it it moans about the static singletons in the Globals.h being unresolved externals.

This is the rough layout of my Globals.h. I'm not quite sure why I'm getting linkage issues with my "Game" project (which doesn't even use any of the singletons at the moment), yet my "Engine" project compiles perfectly. Anyone have any hints as to why this could be happening?


class Globals
{
public:

static void Initialise();
static void Destroy();

static Singleton* GetSingleton()
{
return singleton;
}

private:

static Singleton *singleton;
};
Advertisement
The static declaration is just a declaration so you need to define it elsewhere.
I had indeed declared it elsewhere, the weird thing is I just replaced the NULL with a 0, and it compiled properly. Seems pretty bizarre to me...

This topic is closed to new replies.

Advertisement