First off, I'm able to successfully launch the simple "SFML Works!" app by means of the steps located here:
http://www.sfml-dev.org/tutorials/2.3/start-linux.php.
I'm attempting to get a Git project working on xubuntu.
When I enter:
g++ main.o -o game -lsfml-graphics -lsfml-window -lsfml-system
I get:
main.o: In function `main':
main.cpp:(.text+0x17): undefined reference to `Game::Game()'
main.cpp:(.text+0x26): undefined reference to `Game::run()'
main.cpp:(.text+0x35): undefined reference to `Game::~Game()'
main.cpp:(.text+0x4e): undefined reference to `Game::~Game()'
collect2: error: ld returned 1 exit status
Contents of main.cpp:
#include "Game.hpp"
int main()
{
Game game;
game.run();
}
Contents of Game.cpp:
#include "Game.hpp"
const sf::Time Game::TimePerFrame = sf::seconds(1.f / 60.f);
Game::Game()
: input()
, window(sf::VideoMode(640, 480), "SFML Application")
, map("SampleMap.txt")
, debugger()
{
}
void Game::run()
{
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;
while (window.isOpen())
{
timeSinceLastUpdate += clock.restart();
while (timeSinceLastUpdate > TimePerFrame)
{
timeSinceLastUpdate -= TimePerFrame;
processEvents();
update(TimePerFrame);
}
sf::Time deltaTime = clock.restart();
update(deltaTime);
render();
}
}
void Game::processEvents()
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
}
void Game::update(sf::Time deltaTime)
{
debugger.update(deltaTime);
input.update();
map.player.moveUp = input.cmdUp;
map.player.moveDown = input.cmdDown;
map.player.moveLeft = input.cmdLeft;
map.player.moveRight = input.cmdRight;
map.update(deltaTime);
}
void Game::render()
{
window.clear();
map.render(window);
debugger.render(window);
window.display();
}
Contents of Game.hpp:
#pragma once
#include <SFML/Graphics.hpp>
#include "Map.hpp"
#include "Debugger.hpp"
class Game
{
public:
Game();
~Game();
void run();
private:
void processEvents();
void update(sf::Time deltaTime);
void render();
static const sf::Time TimePerFrame;
Input input;
sf::RenderWindow window;
Map map;
Debugger debugger;
};
G++ / GCC version: 4.9.2 (also tried 4.8.1)
I've tried removing the *.o file and re-compiling using the -std=c++11parameter, but it doesn't appear to make a difference.
Switching from #pragma_once back to #ifndef didn't seem to fix it either - unless I'm using that incorrectly.
The code was originally created on a Windows machine, will I not be able to work on this code in my Linux environment?
All help is greatly appreciated.