Problem with compiling openGL program in Visual C++ .Net

Started by
13 comments, last by LordG 19 years, 7 months ago
Hi, I was trying to compile an OpenGL program in Visual C++ .Net and it generated the following errors. c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1152): error C2144: syntax error : 'void' should be preceded by ';' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1152): error C2501: 'WINGDIAPI' : missing storage-class or type specifiers c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1152): error C2146: syntax error : missing ';' before identifier 'glAccum' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1152): error C2182: 'APIENTRY' : illegal use of type 'void' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1153): error C2144: syntax error : 'void' should be preceded by ';' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1153): error C2501: 'WINGDIAPI' : missing storage-class or type specifiers c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1153): error C2086: 'int WINGDIAPI' : redefinition c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1153): error C2146: syntax error : missing ';' before identifier 'glAlphaFunc' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1153): error C2182: 'APIENTRY' : illegal use of type 'void' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1153): error C2086: 'int APIENTRY' : redefinition c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1154): error C2146: syntax error : missing ';' before identifier 'GLboolean' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1154): error C2501: 'WINGDIAPI' : missing storage-class or type specifiers c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1154): error C2086: 'int WINGDIAPI' : redefinition c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1154): error C2146: syntax error : missing ';' before identifier 'glAreTexturesResident' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1154): error C2371: 'APIENTRY' : redefinition; different basic types c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1155): error C2144: syntax error : 'void' should be preceded by ';' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1155): error C2501: 'WINGDIAPI' : missing storage-class or type specifiers c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1155): error C2086: 'int WINGDIAPI' : redefinition c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1155): error C2146: syntax error : missing ';' before identifier 'glArrayElement' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1155): error C2182: 'APIENTRY' : illegal use of type 'void' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\gl.h(1155): error C2086: 'int APIENTRY' : redefinition This is only a partial list. The rest of the list includes around 200 errors. I don't know what's wrong with it. But I'm sure the error has nothing to do with the actual code, but with the gl.h file. The program I was trying to compile can be found here It's a starter code for a school assignment. I really need to get this working so I can start coding.
Advertisement
Are you including windows.h before the gl.h inclusion?
Ok I just tried including <windows.h> and it still have same error, but it did manage to reduce the number of errors down to around 100.
you have to make sure that you include windows header before any gl header, that includes demo.cpp and polygon.h files.
Change this
#include <iostream>
#include <cstdlib>

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <glui.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

into this

#include <GL/glut.h>

#include <iostream>
#include <cstdlib>

#include <glui.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

[edit]
The above refers to demo.cpp...
[/edit]
Quote:Original post by Anonymous Poster
you have to make sure that you include windows header before any gl header, that includes demo.cpp and polygon.h files.

Nope.
Glut.h includes everything you need in the correct order.
Otherwise it couldn't be cross-platform [wink]
Quote:Original post by darookie
Quote:Original post by Anonymous Poster
you have to make sure that you include windows header before any gl header, that includes demo.cpp and polygon.h files.

Nope.
Glut.h includes everything you need in the correct order.
Otherwise it couldn't be cross-platform [wink]


But he included gl header files before glut.h in demo.cpp and in polygon.h file all he includes is gl.h. So your statemens is zip of value.
Quote:Original post by Anonymous Poster
Quote:Original post by darookie
Quote:Original post by Anonymous Poster
you have to make sure that you include windows header before any gl header, that includes demo.cpp and polygon.h files.

Nope.
Glut.h includes everything you need in the correct order.
Otherwise it couldn't be cross-platform [wink]


But he included gl header files before glut.h in demo.cpp and in polygon.h file all he includes is gl.h. So your statemens is zip of value.

The trick is, you don't need to explicitly include any gl headers when using glut. I didn't look at the polygon.* files so my advice is to just include glut.h instead of any gl headers, which need OS specific headers, too.

So my statement still holds true and you don't seem to have used glut lately.

Yours,
Pat.

[edit]
AP: I just checked these files and noticed an error:
LordG, you should not include headers in header files.
Remove the include statements from polygon.h and include
these files (and use glut.h instead of gl.h) in polygon.cpp.
Thanks to the AP for pointing that out for me [wink]
[/edit]
You've linked all of the library files, right?
Quote:Original post by CoderGuy
You've linked all of the library files, right?

These are compiler errors, not linker errors.
The latter come later [smile].

This topic is closed to new replies.

Advertisement