在Eclipse中编译OpenGL SFML C++项目(使用MinGW作为工具链)时出现了错误:
未定义对
gluNewQuadric@0' undefined reference to
谷四次reference @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程序,我以前也没有遇到过这样的问题。
发布于 2011-12-04 16:38:05
您需要将适当的标志传递给编译器。要包含GLU库,将其传递给编译和链接选项:
-lGLU
编辑:上面的内容可以在linux上运行,但是对于windows,它是:
-lglu32
https://stackoverflow.com/questions/8376772
复制相似问题