SFML community forums

Help => General => Topic started by: JohnGreek on September 11, 2009, 11:12:49 am

Title: SFML on Code::Blocks [linker error]
Post by: JohnGreek 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
Title: SFML on Code::Blocks [linker error]
Post by: Laurent on September 11, 2009, 11:47:40 am
You have to link to libsfml-window, the same way you linked to libsfml-system.
Title: SFML on Code::Blocks [linker error]
Post by: JohnGreek on September 11, 2009, 11:50:21 am
and how exactly i link to that?
Title: SFML on Code::Blocks [linker error]
Post by: Laurent 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.
Title: SFML on Code::Blocks [linker error]
Post by: JohnGreek 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 (http://i708.photobucket.com/albums/ww83/BinPDA/img1.jpg)
Title: SFML on Code::Blocks [linker error]
Post by: Laurent 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.
Title: SFML on Code::Blocks [linker error]
Post by: JohnGreek 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