错误:“未定义对‘gluNewQuadric@0’的引用”
我在 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程序,以前没有出现过这样的问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将适当的标志传递给编译器。要包含 GLU 库,请将其传递给编译和链接选项:
编辑:上面的代码适用于 Linux,但对于 Windows,它是:
You need to pass appropriate flag to the compiler. To include the GLU library, pass this to the compiling and linking options :
EDIT : The above works on linux, but for windows, it is :