Advertisement Jump to content
Sign in to follow this  

Unresolved externals

This topic is 4947 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 {
	// Singleton class
	static FontSystem* m_pInstance;
	FontSystem( void ) { };

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


What am I doing wrong?

Share this post

Link to post
Share on other sites
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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!