Alright, so I'm trying to make a simple game engine using SFML in Visual Studio 2012. What's happening is, I have my header file, Game.hpp:
#ifndef _GAME_H
#define _GAME_H
#include<SFML\Graphics.hpp>
#include<iostream>
class Game
{
private:
sf::RenderWindow Window;
sf::Time ElapsedTime;
sf::Time PreviousTime;
float DeltaTime;
sf::Clock clock;
bool Running;
sf::Event polledEvent;
sf::RectangleShape rectshape;
sf::Font arialFont;
sf::Text testtext;
public:
Game();
int OnExecute();
public:
void Init();
void Update();
void Draw();
void Event(sf::Event polledEvent);
void Cleanup();
};
#endif
and my Game.cpp file for the constructor:
#include "Game.hpp"
Game::Game()
{
Window.create(sf::VideoMode(800,600),"Name Me!");
Window.setFramerateLimit(30);
Running = true;
}
Any changes in the slightest to Game.hpp break compilation, with the linker error:
error LNK2019: unresolved external symbol "public: __thiscall Game::Game(void)" (??0Game@@QAE@XZ) referenced in function _main Program.obj SFML-Project
and the warning:
warning LNK4042: object specified more than once; extras ignored
After forcing it to alternately attempt to rebuild Game.hpp, then Game.cpp(by changing something minor, like adding and deleting a space), it compiles fine. Every single other function is in its own cpp file, and not caring. If Game.hpp doesn't need to be updated, the linker doesn't flag any errors. It is only these two that are fighting.
What causes this error and how to I fix it?
EDIT: I threw all of my implementation code into Game.cpp just to see if that'd do anything. Still the same issue. If I, for example, add a variable to my Game.hpp file, then reference it in a function in my Game.cpp file, it'll go through, build my main file, Game.cpp, and Game.hpp. It'll flag the error. I'll then go through, add a space and backspace, enough to flag the file as "changed," and hit build. It builds without errors.