【发布时间】:2015-12-27 19:19:27
【问题描述】:
我正在使用带有 MinGW 编译器的 Code::Blocks。这些是我的包括:
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
如果我尝试使用函数
glutMainLoopEvent();
它会抛出一个错误:
'glutMainLoopEvent' was not declared in this scope.
功能
glutMainLoop();
虽然效果很好。
如果我尝试同时包含 glut 和 freeglut(我已正确安装它,我确保按照步骤仔细观看了几次视频),如下所示:
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#include <GL/freeglut.h>
#endif
我收到 24 个错误,例如:
undefined reference to `_imp____glutInitWithExit@12'
undefined reference to `_imp____glutCreateWindowWithExit@8'
undefined reference to `glClearColor@16'
但这些不包括我之前遇到的错误!据我所知,我可以包括 glut 或 freeglut,但不能同时包括两者。我该如何解决这个问题?谢谢!
编辑:
链接器选项:
-lfreeglut
-lopengl32
-lglu32
完全消除了问题,现在可以正常工作了。
【问题讨论】:
-
为什么要同时使用 GLUT 和 freeglut?混合(大部分)相同 API 的两个不同实现听起来像是失败的秘诀。
标签: c++ opengl include glut freeglut