Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?
I have created this code
class Game{
static SDL_Surface* screen;
public:
//Initiate Game(SDL_Graphics, folder for output.....)
static void initialize();
static void initializeScreen();
};
void Game::initializeScreen()
{
Game::screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_DOUBLEBUF |SDL_HWSURFACE |SDL_SWSURFACE);
SDL_Init(SDL_INIT_VIDEO);
Game::screen == NULL ? printf("SDL_Init failed: %s\n", SDL_GetError()):printf("SDL_Init initialized\n");
SDL_WM_SetCaption("SDL Animation", "SDL Animation");
}
It compiles but I get e linker error, how can I fix this?
1>game.obj : error LNK2001: unresolved external symbol "private: static struct SDL_Surface * Game::screen" (?screen@Game@@0PAUSDL_Surface@@A)
Edit: This is how I fixed it, in game.cpp added this
SDL_Surface* Game::screen;
outside of any function*