how could the .h file be wrong?

hi, i m completely new to openGL.

when i tried to compile a sample code downloaded from the net, my MS VisualC++ give me error:
--------------------Configuration: e - Win32 Debug--------------------
Compiling…
e.cpp
d:\gl\gl.h(1135) : error C2144: syntax error : missing ‘;’ before type ‘void’
d:\gl\gl.h(1135) : error C2501: ‘WINGDIAPI’ : missing storage-class or type specifiers
d:\gl\gl.h(1135) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

e.obj - 3 error(s), 0 warning(s)


i didn’t modify the file at all, how can the gl.h have syntax error?? i tried doing it with other sample code from the net and got the same result. anyone know whats wrong here?
thanksss

william ng

When using OpenGL in windows you MUST #include <windows.h> before gl.h
I suspect this is the problem being as WINGDIAPI is defined in windows.h

ya!! it worked! thanks!!

now i got another one, when i try to build it. i got this:
--------------------Configuration: e - Win32 Debug--------------------
Linking…
LINK : fatal error LNK1104: cannot open file “opengl32.dll”
Error executing link.exe.

e.exe - 1 error(s), 0 warning(s)


i am sure that opengl32.dll is in my windows/system/ .it didn’t tell me what is wrong. is there anything i can try???

thank you so much!!

william ng

You are not supposed to add opengl32.dll to your project, try with opengl32.lib instead.

Bob, I have included a DLL in my project (with Borland C++ back then) and without the LIB and have gotten programs to link properly

Is there any reason why it shouldn’t work?

Ah, yeah, I apologize, you CAN add a dll file into your project. But maybe I expressed myself a tad wrong. If you add opengl32.dll to your project in the Link-tab under Project->Settings (MSVC 6), you will get this error, because the linker can’t find the file, unless you keep the dll-file in your lib-directory. This is the place where you should replace .dll with .lib

I got same problem, and I put the head file like this,
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#include <gl\glaux.h>

but when building, it shows error message:
error C2144: syntax error : missing ‘;’ before type ‘void’

why?

You dont’t say very much but i’d guess there is a undefined identifier near the place VC tells you about the error.

Nice way to celebrate a thread’s 2 year anniversary .

Thanks for reply.

I find answer in another post. The glut.h already include gl.h and glu.h, so I don’t need include them again.