Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Debian Linux]I'm getting some odd errors when trying to compile  (Read 3319 times)

0 Members and 1 Guest are viewing this topic.

carton83

  • Newbie
  • *
  • Posts: 38
    • View Profile
[Debian Linux]I'm getting some odd errors when trying to compile
« on: November 15, 2013, 09:03:03 pm »
This is my code

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window;
    window.create(sf::VideoMode(400, 400), "Test!");
    window.setFramerateLimit(4);
    sf::Event event;

    while(window.isOpen())
    {
        while(window.pollEvent(event));
        {
            switch (event.type)
            {
            case sf::Event::Closed:
                window.close();
                break;
            default:
                window.clear(sf::Color(134,0,0));
                window.display();
            }
        }
    }
    window.close();
    return 0;
}

If I run

g++ -o -v main.cpp -lsfml-graphics

and I get

/usr/bin/ld: /tmp/ccduJuDb.o: undefined reference to symbol '_ZN2sf6Window17setFramerateLimitEj'
/usr/lib/libsfml-window.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

But if I run

g++ -o main.cpp -lsfml-graphics

I get this and my main.cpp file is deleted.

What am I doing wrong?

Oh, and I just try compiling in Code Blocks, I get a bunch of undefined reference errors.
« Last Edit: November 15, 2013, 09:04:44 pm by carton83 »

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: [Debian Linux]I'm getting some odd errors when trying to compile
« Reply #1 on: November 15, 2013, 09:29:48 pm »
Don't forget that you also need to link to the modules that certain modules rely on. If you link to sfml-graphics, you also need to link to sfml-window and sfml-system.
DSFML - SFML for the D Programming Language.

lockandstrike

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: [Debian Linux]I'm getting some odd errors when trying to compile
« Reply #2 on: November 15, 2013, 11:42:00 pm »
It's also important that you link them in the correct order. Like so:

g++ main.cpp -o  main -lsfml-graphics -lsfml-window -lsfml-system