Reputation: 7806
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 : 'void' should be preceded by ';'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2146: syntax error : missing ';' before identifier 'glAccum'
etc.
Upvotes: 27
Views: 25799
Reputation: 21
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"
Upvotes: 2
Reputation: 994
Just #include <windows.h>
before <gl/gl.h>
or <gl/glu.h>
.
It is needed for some types, such as WINGDIAPI
and APIENTRY
.
Upvotes: 59
Reputation: 163247
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.
Upvotes: -1
Reputation: 140032
Sounds like you're including a C header inside a C++ project. Try enclosing your include statement inside:
extern "C" {
#include "gl.h"
}
Upvotes: 3