eclipse 上 openGl 的问题

发布于 2024-09-02 16:18:22 字数 2374 浏览 3 评论 0原文

我正在使用 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

,请有人帮忙我,提前谢谢

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

please can somebody help me, thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪是无色的血 2024-09-09 16:18:23

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

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"

执手闯天涯 2024-09-09 16:18:22

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

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

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

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".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文