user2978111
user2978111

Reputation: 23

The moment I add glew.h in my code glut related errors start appearing

I am new to C/C++ environment setup. Right now I am using Eclipse IDE. Below are the steps I have followed After installing MinGW and running basic HelloWorld, C program 1) Copied glew32.dll and glut32.dll to "C:\MinGW\bin" 2) Copied gl.h, glew.h, glu.h and glut.h to "C:\MinGW\include\GL" 3) Copied glew32.lib, glut32.lib and OPENGL32.LIB to "C:\MinGW\lib" 4) In Project->properties->C/C++ Build->Settings->Tool Settings->MinGW C Linker->Libraries(-l) added "glew32", "glut32","glu32" and "opengl32" 5) Copied below code

Compiles properly.

The moment I uncomment the first line, ie glew.h, glut related compile errors (added below) appear, Can any one tell me where I am going wrong during setup?

//#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

//ignore

Upvotes: 0

Views: 1059

Answers (1)

Berke Cagkan Toptas
Berke Cagkan Toptas

Reputation: 1034

From glew webpage [delete gl include] :

Using GLEW as a shared library

in your program:

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

or:

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

Remember to link your project with glew32.lib, glu32.lib, and opengl32.lib on Windows and libGLEW.so, libGLU.so, and libGL.so on Unix (-lGLEW -lGLU -lGL). It is important to keep in mind that glew.h includes neither windows.h nor gl.h. Also, GLEW will warn you by issuing a preprocessor error in case you have included gl.h, glext.h, or glATI.h before glew.h.

Upvotes: 1

Related Questions