gl.h giving me problems

It’s probably something I’ve missed, but it’s been working ok before.

I’ve got VC++6.0 and I’m starting to learn OpenGL, I’ve found some code using GLUT which makes creating windows etc easier.

When I build the code it comes up with 3 errors:

missing ‘;’ before type void
WINGDIAPI missing storage-class…
Unexepected end of file found

These are found in the gl.h file, which is pretty werid seeming I’ve been using it before. Becuase I’ve hjust started putting GLUT stuff in I expect it doesn’t like that. I have linked the .lib files in VC++ so it’s not that, as I said I’ve been compiling code before ok from the NeHe site.

Can anyone offer any light on this? Thanks in advance.

Sometimes that problem can be caused by the order that you included the files. I know you said that you’ve included all the libraries, but make sure you have both opengl32.lib, glut32.lib, and glu32.lib (if you’re using glu) imported.

This might be happening because you’re doing something like this:

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

This can cause a problem because gl.h uses some symbols (e.g. WINGDIAPI) that need to be defined before gl.h is included. Luckily, glut.h will do this for you. So try replacing the above code with:

#include <GL/glut.h>

And see if it works. glut.h will automatically include gl.h and glu.h for you.

Can you post the #includes that you’re using? That might help.


[This message has been edited by Owlet (edited 11-15-2001).]

[This message has been edited by Owlet (edited 11-15-2001).]

What you said works :stuck_out_tongue:

Yeah I read that glut includes gl.h and glu.h but it never really goes through your head.


One solution to the problem is to include <GL/glut.h>, as Owlet said. Another is to include <windows.h> before <GL/gl.h>. This is the solution you are looking for if you sometime plan to drop GLUT.