SFML community forums

Help => Window => Topic started by: joske on December 20, 2012, 06:18:47 pm

Title: OpenGL undefined references
Post by: joske on December 20, 2012, 06:18:47 pm
Hi guys, I'm going through the tutorials of this site, and am currently trying to draw a cube ><
So, when I want to compile the program,


undefined reference to glClearDepth@8

pops up as an error, and the same goes with all the OpenGL functions.. Isn't OpenGL header contained in the window.hpp ?
Title: Re: OpenGL undefined references
Post by: Laurent on December 20, 2012, 06:22:26 pm
Headers and libraries aren't the same thing. When you include OpenGL headers, the compiler knows that OpenGL functions exist. But then it doesn't tell the linker where to find them: for that you must link to the OpenGL library.
Title: Re: OpenGL undefined references
Post by: joske on December 20, 2012, 06:33:15 pm
Yea, but I added the sfml-window and sfml-system library in the Project build options.. I do not get an error in the line where I use sf::Clock
Title: Re: OpenGL undefined references
Post by: masskiller on December 20, 2012, 07:01:51 pm
The fact that SFML uses openGL doesn't mean that if you link SFML it will link OpenGL from beneath, as SFML is already compiled it doesn't need to, whereas you need to tell the linker where the OpenGL implementations are as they are not given anywhere else, which means that you have to link any OpenGL dependency you are using.
Title: Re: OpenGL undefined references
Post by: joske on December 20, 2012, 07:33:17 pm
Added them , it works :) Thanks, hope I didn't bother you too much..