eclipse上openGl的问题

时间:2010-05-18 13:43:29

标签: c eclipse opengl mingw glut

我正在使用Windows XP我有Eclipse Galileo的可移植版本,但我没有找到过剩,所以我决定使用这个link添加它我做了所有步骤而现在我正在尝试编译此代码

#include "GL/glut.h"
#include "GL/gl.h"
#include "GL/glu.h"

///////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
 {
 // Clear the window with current clearing color
 glClear(GL_COLOR_BUFFER_BIT);


 // Flush drawing commands
    glFlush();
 }

///////////////////////////////////////////////////////////
// Setup the rendering state
void SetupRC(void)
    {
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    }

///////////////////////////////////////////////////////////
// Main program entry point
void main(int argc, char* argv[])
 {
 glutInit(&argc, argv);
 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize(800,600);
 glutCreateWindow("Simple");
 glutDisplayFunc(RenderScene);

 SetupRC();

 glutMainLoop();
    }

我有这个错误

Simple.o: In function `RenderScene':
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:16: undefined reference to `_imp__glClear'
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:20: undefined reference to `_imp__glFlush'
Simple.o: In function `SetupRC':
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:27: undefined reference to `_imp__glClearColor'
Simple.o: In function `main':
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:34: undefined reference to `glutInit'
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:35: undefined reference to `glutInitDisplayMode'
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:36: undefined reference to `glutInitWindowSize'
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:37: undefined reference to `glutCreateWindow'
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:38: undefined reference to `glutDisplayFunc'
C:/Documents and Settings/Administrator/Desktop/workspace/open/Debug/../Simple.c:42: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status

请有人帮助我,提前谢谢

2 个答案:

答案 0 :(得分:2)

看起来您没有链接OpenGL,GLU或GLUT库。您需要告诉Eclipse链接它们,并且您需要告诉它存储它们的目录(至少对于大多数IDE,这两个操作是彼此分开的。)

如果内存服务,openGL本身将是opengl32.lib。如果它合理安装开始,IDE可能已经知道该库的位置(即,它是Windows的正常部分,并且该库将与其他正常的Windows库一起)。 glu函数位于glu32.lib中,它应位于同一位置。

Glut通常位于名为glut32.lib的文件中。假设您在C盘的根目录中安装了Glut,它通常位于“C:\ glut-3.7 \ lib \ glut”。

答案 1 :(得分:0)

您似乎错过了添加库并且链接器无法找到它们。确保在“库”对话框中指定了正确的库。我这里没有Eclipse安装,但是这个对话框应该在“右键单击项目 - >周围。属性 - > Libraries / C ++ Linker“