Jump to content
  • Advertisement
Sign in to follow this  
LordG

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

This topic is 5468 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you have to make sure that you include windows header before any gl header, that includes demo.cpp and polygon.h files.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Guest 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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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].

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!