我在我的代码中添加glew.h的那一刻相关的错误开始出现

时间:2015-04-01 14:54:49

标签: eclipse opengl mingw glut glew

我是C / C ++环境设置的新手。现在我正在使用Eclipse IDE。以下是我遵循的步骤 安装MinGW并运行基本的HelloWorld,C程序后 1)将glew32.dll和glut32.dll复制到" C:\ MinGW \ bin" 2)将gl.h,glew.h,glu.h和glut.h复制到" C:\ MinGW \ include \ GL" 3)将glew32.lib,glut32.lib和OPENGL32.LIB复制到" C:\ MinGW \ lib" 4)在Project-> properties-> C / C ++ Build-> Settings-> Tool Settings-> MinGW C Linker-> Libraries(-l)添加" glew32",&# 34; glut32"" glu32"和" opengl32" 5)复制下面的代码

正确编译。

我取消注释第一行的那一刻,即glew.h,出现了与过滤相关的编译错误(在下面添加),任何人都可以告诉我在设置过程中出错了吗?

//#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glut.h>

void changeViewport(int w, int h)
{
    glViewport(0, 0, w, h);
}

void render()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSwapBuffers();
}


int main(int argc, char** argv)
{
    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutInitWindowSize(800, 600);
    glutCreateWindow("Pinnen is the best");
    glutReshapeFunc(changeViewport);
    glutDisplayFunc(render);
    glutMainLoop();
    return 0;
}


Description Resource    Path    Location    Type
undefined reference to `__glutCreateMenuWithExit'   OpenGL      line 549, external location: c:\mingw\include\GL\glut.h C/C++ Problem
undefined reference to `__glutCreateWindowWithExit' OpenGL      line 503, external location: c:\mingw\include\GL\glut.h C/C++ Problem
undefined reference to `__glutInitWithExit' OpenGL      line 486, external location: c:\mingw\include\GL\glut.h C/C++ Problem
undefined reference to `glutDisplayFunc'    OpenGL.c    /OpenGL/src line 25 C/C++ Problem
undefined reference to `glutInitDisplayMode'    OpenGL.c    /OpenGL/src line 21 C/C++ Problem

//忽略

1 个答案:

答案 0 :(得分:1)

来自glew webpage [删除gl include]:

将GLEW用作共享库

在您的计划中:

#include <GL/glew.h>
#include <GL/glut.h>
<gl, glu, and glut functionality is available here>

或:

#include <GL/glew.h>
<gl and glu functionality is available here>

请记住将您的项目与Windows上的glew32.lib,glu32.lib和opengl32.lib以及Unix上的libGLEW.so,libGLU.so和libGL.so(-lGLEW -lGLU -lGL)相关联。 重要的是要记住glew.h既不包括windows.h也不包括gl.h.此外,如果您在glew.h之前包含了gl.h,glext.h或glATI.h,GLEW会通过发出预处理器错误来警告您。