Compiling a file that uses OpenGL with Visual C++, when I try to include the gl.h header file I get about 150 unhelpful compile errors:
error C2144: syntax error : \'voi
The first possibility to consider is that the compiler's messages are actually right. Surely there were line numbers included in those error messages, so have you looked at the offending lines, and some of the lines preceding them, to try to identify what might really be the cause?
Were there any other messages that came before the ones you've cited? (A missing header, for instance?) Always start addressing compiler messages from the first one; later ones are sometimes just side effects caused by that.
Can you reproduce the problem in a simple project? Is it enough to just write #include <gl.h>
in an otherwise empty file and try to compile it? Or is there more about this source code that causes the error to occur?
Remember that you're the one here with access to your code; the questions I'm asking above are the sorts of things you need to consider since you can't always have someone else debug your code for you.
Sounds like you're including a C header inside a C++ project. Try enclosing your include statement inside:
extern "C" {
#include "gl.h"
}
Just #include <windows.h>
before <gl/gl.h>
or <gl/glu.h>
.
It is needed for some types, such as WINGDIAPI
and APIENTRY
.
if you use visual c++, make sure you already have the opengl library.
use #include <windows.h>
before the #include <GL/gl.h>
and if you use #include <glut.h>
in your program make sure you are not type like this
#include <GL/glut.h>
, if you type like that it can be error "GL/glut.h no such file or directory"