I was working with some c++ code from a site. When i try to link in dev c++ I get this.

[Linker error] undefined reference to `GameEngine::m_pGameEngine'

The code compiles perfectly but does not link.

class GameEngine
   // Member Variables
   static GameEngine*  m_pGameEngine;
   HINSTANCE           m_hInstance;
   HWND                m_hWindow;
   TCHAR               m_szWindowClass[32];
   TCHAR               m_szTitle[32];
   WORD                m_wIcon, m_wSmallIcon;
   int                 m_iWidth, m_iHeight;
   int                 m_iFrameDelay;
   BOOL                m_bSleep;

   // Constructor(s)/Destructor
           GameEngine(HINSTANCE hInstance, LPTSTR szWindowClass,
             LPTSTR szTitle, WORD wIcon, WORD wSmallIcon, int iWidth = 640,
             int iHeight = 480);
   virtual ~GameEngine();

   // General Methods
   static GameEngine*  GetEngine() { return m_pGameEngine; };
   BOOL                Initialize(int iCmdShow);
   LRESULT             HandleEvent(HWND hWindow, UINT msg, WPARAM wParam,
                         LPARAM lParam);

   // Accessor Methods
   HINSTANCE GetInstance() { return m_hInstance; };
   HWND      GetWindow() { return m_hWindow; };
   void      SetWindow(HWND hWindow) { m_hWindow = hWindow; };
   LPTSTR    GetTitle() { return m_szTitle; };
   WORD      GetIcon() { return m_wIcon; };
   WORD      GetSmallIcon() { return m_wSmallIcon; };
   int       GetWidth() { return m_iWidth; };
   int       GetHeight() { return m_iHeight; };
   int       GetFrameDelay() { return m_iFrameDelay; };
   void      SetFrameRate(int iFrameRate) { m_iFrameDelay = 1000 /
               iFrameRate; };
   BOOL      GetSleep() { return m_bSleep; };
   void      SetSleep(BOOL bSleep) { m_bSleep = bSleep; };

What am I doing wrong or how can I change it.

8 Years
Discussion Span
Last Post by Clockowl

You need to include a .lib, .dll or .a file from the library you are using I guess. What are you exactly doing/trying to do?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.