我在Eclipse中编译OpenGL SFML C ++项目时遇到错误(使用MinGW作为工具链):
对'gluNewQuadric @ 0'的未定义引用
未定义引用`gluQuadricDrawStyle @ 8'
未定义对`gluDeleteQuadric @ 4
的引用
违规代码在这里:
#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;
我做错了什么?通常,我在Java中编写代码,而这个项目是为了更多地了解C / C ++而做的。之前我做过其他的OpenGL程序,之前我没有这样的问题。
答案 0 :(得分:7)
您需要将适当的标志传递给编译器。要包含GLU库,请将其传递给编译和链接选项:
-lGLU
编辑:以上适用于Linux,但对于Windows,它是:
-lglu32