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

Author Topic: SFML on Code::Blocks [linker error]  (Read 5457 times)

0 Members and 1 Guest are viewing this topic.

JohnGreek

  • Newbie
  • *
  • Posts: 43
    • View Profile
SFML on Code::Blocks [linker error]
« on: September 11, 2009, 11:12:49 am »
Heya, this is my first post here and i'd like to say hi to everybody :D
now to the point:

I am using Dev C++ as IDE and when i try to compile the simplest window app(just using window.hpp) i keep getting those errors:
--------------------
 In function `main':
  [Linker error] undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
  [Linker error] undefined reference to `sf::Window::Window(sf::VideoMode, std::string const&, unsigned long, sf::WindowSettings const&)'
  [Linker error] undefined reference to `sf::Window::Display()'
  [Linker error] undefined reference to `sf::Window::~Window()'
  [Linker error] undefined reference to `sf::Window::~Window()'
  ld returned 1 exit status  
--------------------
I just don't understand why i get those link errors.
I did a small search and i found that those errors occur when i am using a function that is not inside the headers i include but i think everything is fine...
I have tried everything(look for other tutorials, rewrite the code a hundred times) but still nothing.
I am kinda newbie to libraries so i could use some help :P

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML on Code::Blocks [linker error]
« Reply #1 on: September 11, 2009, 11:47:40 am »
You have to link to libsfml-window, the same way you linked to libsfml-system.
Laurent Gomila - SFML developer

JohnGreek

  • Newbie
  • *
  • Posts: 43
    • View Profile
SFML on Code::Blocks [linker error]
« Reply #2 on: September 11, 2009, 11:50:21 am »
and how exactly i link to that?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML on Code::Blocks [linker error]
« Reply #3 on: September 11, 2009, 12:32:16 pm »
This is explained in the "getting started" tutorial. There's none for Dev-C++, but it should be similar to Code::Blocks.

By the way, you should throw away Dev-C++ (which died a long time ago) and use a more recent IDE like Code::Blocks.
Laurent Gomila - SFML developer

JohnGreek

  • Newbie
  • *
  • Posts: 43
    • View Profile
SFML on Code::Blocks [linker error]
« Reply #4 on: September 11, 2009, 01:56:54 pm »
thx for your fast reply :)
well, yeah you are right, devcpp is long ago abandoned...
so i downloaded code blocks and i configured it but i get the same errors like devcpp.
i made all the steps many times, added the includes and the library, but still no luck.

SS of the compiler

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML on Code::Blocks [linker error]
« Reply #5 on: September 11, 2009, 03:35:01 pm »
Like explained in the tutorial, you need to link to sfml-system for this piece of code.
Laurent Gomila - SFML developer

JohnGreek

  • Newbie
  • *
  • Posts: 43
    • View Profile
SFML on Code::Blocks [linker error]
« Reply #6 on: September 11, 2009, 03:50:04 pm »
but that's the point, i did everything step-by-step on the tutorial for Code Blocks and still it's not working, i get the the same errors.
those errors mean the sfml-system library is not linked...
i just don't understand what i'm doing wrong :/

EDIT: i got it working, thx for your help