Multiple Definitions

I've come up with a sample code that works great with SFML 2.1, but when I add a string of text, specify what font, font size, color, and string, I get a whole bunch of compile-time errors which state that there are multiple references to every single data type, function, etc, in the main source file. What is happening?!

How can I define keywords when I'm just adding in some text to print (which I haven't even got to printing it yet)? The sample code is not direct from Code::Blocks' included sample. Here's the main source file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <SFML/Graphics.hpp>

int main() {
    sf::RenderWindow window(sf::VideoMode(1366, 768), "Sample?");
    sf::Font font;
    font.loadFromFile("dos.ttf");
    sf::Text text;
    text.setString("Hello");
    text.setColor(sf::Color(0, 255, 0));
    text.setFont(font);
    text.setCharacterSize(10);

    while (window.isOpen()) {
        sf::Event event;
            while (window.pollEvent(event)) {
                if (event.type == sf::Event::Closed)
                window.close();
            }
        window.clear();

        window.draw(text);

        window.display();
    }

    return EXIT_SUCCESS;
}


I seriously don't know how I can have multiple definitions when I have only added some text and only have one header file included. What is causing this error?
Last edited on
How are you linking to SFML? You may be getting multiple definitions from the standard library if both you and SFML linked to it.
Last edited on
Topic archived. No new replies allowed.