Original Post
hi all,
i''ve got a static library with a class with a static member. In my application i get those link errors:
estGame.obj : error LNK2001: unresolved external symbol "private: static class iInput * cInputTask::input" (?input@cInputTask@@0PAViInput@@A)
Engine.lib(cInputTask.obj) : error LNK2001: unresolved external symbol "private: static class iInput * cInputTask::input" (?input@cInputTask@@0PAViInput@@A)
the class in my static lib
.h:
#ifndef CINPUTTASK
#define CINPUTTASK
#include <windows.h>
#include "InputInc.h"
#include "assert.h"
#include "cInputTask.h"
#include "iTask.h"
class cInputTask : public iTask
{
public:
cInputTask();
~cInputTask();
void init(char *dllName,HINSTANCE hInst,HWND hWnd);
bool start();
bool update();
void stop();
static inline iInput* getInputObj(){return input;}
private:
cInputFactory *factory;
static iInput *input;
HINSTANCE hInst;
HWND hWnd;
char *dllName;
};
#endif
.cpp:
#include "stdafx.h"
#include "cInputTask.h"
iInput cInputTask::*input = NULL;
cInputTask::cInputTask()
{
factory = NULL;
this->hInst = NULL;
this->hWnd = NULL;
dllName = NULL;
}
cInputTask::~cInputTask()
{
}
void cInputTask::init(char *dllName,HINSTANCE hInst,HWND hWnd)
{
this->hInst = hInst;
this->hWnd = hWnd;
this->dllName = dllName;
}
bool cInputTask::start()
{
assert(hInst!=NULL||hWnd!=NULL||dllName!=NULL);
//create input
factory = new cInputFactory(hInst);
factory->initInterface(dllName);
input = factory->getInput();
if(input == NULL)
return false;
if(input->init() == false)
return false;
input->setHWND(hWnd);
//input->update();
return true;
}
bool cInputTask::update()
{
input->update();
return true;
}
void cInputTask::stop()
{
factory->destroyInterface();
}
the class in my application:
#ifndef GAMESTATE1
#define GAMESTATE1
#include "Engine Includes.h"
class gameState1 : public iTask
{
public:
bool start()
{
return true;
}
bool update()
{
if(cInputTask::getInputObj()->keyPressed(DIK_ESCAPE))
cKernel::getSingleton().endRun = true;
return true;
}
void stop()
{
}
private:
};
#endif