Getting OpenGL to work

Hi, I’m learning OpenGL and I’ve downloaded Lesson #1 from NeHe . When I try to compile I get 115 errors, here are a few:

c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(60) : error C2143: syntax error : missing ';' before '*'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(60) : error C2734: 'GLubyte' : const object must be initialized if not extern
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(61) : error C2065: 'GLenum' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(61) : error C2146: syntax error : missing ')' before identifier 'errCode'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(61) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(61) : error C2501: 'gluErrorString' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(61) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(64) : error C2146: syntax error : missing ')' before identifier 'errCode'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(64) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(64) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(66) : error C2143: syntax error : missing ';' before '*'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(66) : error C2734: 'GLubyte' : const object must be initialized if not extern
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(66) : error C2086: 'const int GLubyte' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(60) : see declaration of 'GLubyte'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(67) : error C2146: syntax error : missing ')' before identifier 'name'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(67) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(67) : error C2501: 'gluGetString' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(67) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\gl\GLU.h(70) : error C2065: 'GLdouble' : undeclared identifier

I’m linking the libraries like this:

/MACHINE:I386 opengl.lib glu32.lib glaux.lib kernel32.lib

and I use MSVS .NET. What am I doing wrong?

Thanks in advance

try including windows.h before gl.h and glu.h.

:slight_smile:

I’ve already done that, here are my includes:

#include <windows.h>		
#include <gl\gl.h>			
#include <gl\glu.h>			
#include <gl\glaux.h>

:wink:

i think you want to link with opengl32.lib, not opengl.lib.

the errors you posted, are they the first few listed? (generally thats what we want to look at)
it looks like some things arent defined - types and so on. that generally indicates some header trouble…

i dont use vc7, so im just hinting to some common problems with vc6.

The opengl32.lib was a typo :stuck_out_tongue:

Yes these are the first errors on the list.
As you can see they occur in GL.h, all the following errors occur in the other two OpenGL includes. Only thing to do is solve this :confused:

hmm, dunno. i know that with vc6, windows.h includes the definitions for WINGDIAPI and APIENTRY (both are needed by gl).

maybe someone who uses vc7 can suggest something…

:slight_smile:

You seem to be doing everything ok.
What happens, if you downloads Nehe´s VS 7 code and open that workspace? Does it compile then?

Jan.

I also link with kernel32.lib.

I downloaded the VS .NET code here
The weirdest thing is the errors occur in the headers. I’d really appreciate it if you try the NeHe code on your compiler to see if it works :slight_smile: