Error: “undefined reference to `gluNewQuadric@0'”
Question
I have an errors during compilation of OpenGL SFML C++ project in Eclipse (using MinGW as toolchain):
undefined reference to `gluNewQuadric@0'
undefined reference to `gluQuadricDrawStyle@8'
undefined reference to `gluDeleteQuadric@4
The offending code is here:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
sf::WindowSettings Settings;
Settings.AntialiasingLevel = 2;
Settings.DepthBits = 24;
Settings.StencilBits = 8;
sf::Window App(sf::VideoMode(1024, 768, 32), "SFML Window", sf::Style::Close, Settings);
App.SetFramerateLimit(30);
prepareGL(App.GetWidth(), App.GetHeight());
sf::Clock Clock;
App.SetActive();
// GL goes here:
GLUquadricObj *qw1 = gluNewQuadric();
gluQuadricDrawStyle(qw1,GLU_POINT);
App.Display();
while (App.IsOpened()) {
sf::Event Event;
while (App.GetEvent(Event)) {
if (((Event.Type == sf::Event::KeyPressed)
&& (Event.Key.Code == sf::Key::Escape))
|| (Event.Type == sf::Event::Closed)) {
gluDeleteQuadric(qw1);
App.Close();
}
if (Event.Type == sf::Event::Resized) {
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
}
}
}
return EXIT_SUCCESS;
What I did wrong? Usually, I code in Java, and this project I am doing for learning more about C/C++. I did other OpenGL programs before, and I had no problems like that before.
Solution
You need to pass appropriate flag to the compiler. To include the GLU library, pass this to the compiling and linking options :
-lGLU
EDIT : The above works on linux, but for windows, it is :
-lglu32
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow