我在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

有人能帮我吗?谢谢

最佳答案

看起来您没有链接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”。

关于c - Eclipse上的openGl问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2857782/

10-13 05:54