Jump to content
  • Advertisement
Sign in to follow this  
Mizipzor

Unresolved externals

This topic is 4822 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

Im using something Ive learned from an article called "singleton pattern" so I can make sure only one instance of the class exists. I made the graphic class singleton, worked fine. But when I tried to do it on the font class it did not... Too me it looks like I made them identical. But apparently, I did not. I get this error:
Game.obj : error LNK2001: unresolved external symbol "protected: static class FontSystem * FontSystem::m_pInstance" (?m_pInstance@FontSystem@@1PAV1@A)

This is the class (cut down version)
#ifndef _FONT
#define _FONT

class FontSystem {
protected:
	// Singleton class
	static FontSystem* m_pInstance;
	FontSystem( void ) { };


public:
	// Singleton ---
	static FontSystem* GetInstance( void ) {
		if ( !m_pInstance )
			m_pInstance = new FontSystem();
		return m_pInstance;
	};
};

#endif

What am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
In one source file (.cpp) at namespace level (not inside a class or a function) put:

FontSystem * FontSystem::m_pInstance;

Share this post


Link to post
Share on other sites
You have declared but not defined your static variable. You need to add FontSystem* FontSystem::m_pInstance; to a (single!) source file.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!