Link to home
Start Free TrialLog in
Avatar of antaren
antaren

asked on

Linker Problem, Please Help: Skeleton.obj : error LNK2001: unresolved external symbol "protected: static class GameEngine * GameEngine::m_pGameEngine" (?m_pGameEngine@GameEngine@@1PAV1@A)

I am creating a simple game engine, to get my feet wet.

The program I've created compiles, but it does not link correctly.  It gives the following error:

Skeleton.obj : error LNK2001: unresolved external symbol "protected: static class GameEngine * GameEngine::m_pGameEngine" (?m_pGameEngine@GameEngine@@1PAV1@A)

I've google'ed for a solution, but all the results come back about missing library dependancies or directions on including header files into the project, neither of which I believe to be the problem.

I'm pritty sure its a problem with how I'm using the GameEngine class in my program.  Here is the main referance for the member variable m_pGameEngine:

In class GameEngine

     // GetEngine method allows outside access to the GameEngine pointer
     static GameEngine*  GetEngine() { return m_pGameEngine; };

In GameEngine::GameEngine()

      // Set the member variables for the game engine
      m_pGameEngine = this;

Thanks for the help.
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To explain more, every static data member must be initialized to some value, normally this initialization is made in the .cpp file of the class implementation (not in .h file because it can't initialized many times).
In this case, the pointer will be initialized to NULL, then, in the constructor will be re-initialized to the proper value.
Avatar of antaren
antaren

ASKER

Thanks allot man.

Initialized it before any function calls, and it works like a charm now.