Jump to content
  • Advertisement
Sign in to follow this  
Whorse

Singleton Unresolved External in Other Library

This topic is 2621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
};

Share this post


Link to post
Share on other sites
Advertisement
The static declaration is just a declaration so you need to define it elsewhere.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!