开发者

problems with openGl on eclipse

I'm working on Windows XP I have portable version of Eclipse Galileo, but I didn't find there glut so I decided to add it using this link I made all steps and and now I'm trying to compile this code

#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();
    }

and I have this errors

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

plea开发者_运维技巧se can somebody help me, thanks in advance


It looks like you're not linking the OpenGL, GLU or GLUT libraries. You need to tell Eclipse to link them, and you need to tell it the directories where they're stored (at least with most IDEs, the two operations are separate from each other).

If memory serves, openGL itself will be opengl32.lib. If it installed reasonably to start with, the IDE will probably already know the location for this library (i.e., it's a normal part of Windows, and the library will be along with the other normal Windows libraries). The glu functions are in glu32.lib, which should be in the same place.

Glut will normally be in a file named glut32.lib. Assuming you installed Glut in the root directory of your C drive, it would typically be at "C:\glut-3.7\lib\glut".


It seems that you have missed to add the libraries and the linker cannot find them. Make sure that the correct libraries are specified in the Libraries dialog. I don't have a Eclipse installation here but this dialog should be somewhere around `Right click project -> Properties -> Libraries/C++ Linker"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜