Archived

This topic is now archived and is closed to further replies.

The GL.H file for C++ compiler

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

Recommended Posts

Hi. I downloaded some toturials from a web page, and I read them, and I think I understood as well. But when I came to the point where I was supposed to compile the 3D model/object (using SDL), I get an annoying error from the compiler. Somehow it seems that the GL.H header file is either corrupt, or too old for the program. Therefor I was wondering if someone of you knew the location of a working GL.H file... HunterX

Share on other sites
What compiler?
What errors, exactly?

Share on other sites
I use the MSVisual C++ compiler, and I get the compile error:

d:\.....\gl\gl.h(1152) : error C2144: syntax error : missing '';'' before type ''void''

d:\.....\gl\gl.h(1152) : error C2501: ''WINGDIAPI'' : missing storage-class or type specifiers

d:\.....\gl\gl.h(1152) : fatal error C1004: unexpected end of file found

Since nearly the same line continues downwards in the GL.H file, I would suppose that the same errors would occur downwards, but I''m not certain.

Share on other sites
...which version of the MSVC compiler would that be?

Share on other sites
Are you including window.h before the OpenGL header?

With the GL libs that came with MSVC++ 6 you need to include the windows header before the GL headers.

Share on other sites
Yep, you haven''t included windows.h first. Do this:

#define WIN32_LEAN_AND_MEAN#include <windows.h>//and THEN do this#include <GL/gl.h>

Share on other sites
If gl.h requires windows.h to be included, why isn''t it including it itself?

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]

Share on other sites
quote:
Original post by Arild Fines
If gl.h requires windows.h to be included, why isn''t it including it itself?

It''s halfway to platform independence. GL.h doesn''t really need Windows.h, it just isn''t as good as the other Platform SDK headers at defining what it needs. The only unrecognized identifiers in GL.h are WINGDIAPI and APIENTRY, which can be declared as __declspec(dllimport) and __stdcall, respectively.

"Sneftel is correct, if rather vulgar." --Flarelocke

Share on other sites
The first section of glut.h does Win32 stuff for gl.h on windows without including windows.h. Windows.h can be very heavy if you don''t need most of it, and that''s a decent way to go.

Share on other sites
quote:
Original post by Promit
Yep, you haven''t included windows.h first. Do this:

#define WIN32_LEAN_AND_MEAN#include <windows.h>//and THEN do this#include <GL/gl.h>

Thanks, but when I do this, I get a lot of new error messages.
E.G. Main.obj : error LNK2001: unresolved external symbol __imp__glEnd@0

There are also 21 other similar errors...

Share on other sites

if you want to do it programatically, do this:
#pragma comment(lib, "opengl32.lib")

Share on other sites
quote:
Original post by superdeveloper

if you want to do it programatically, do this:
#pragma comment(lib, "opengl32.lib")

Thanks, but still I have remaining errors (only 14 left...).
E.G. Main.obj : error LNK2001: unresolved external symbol __SDL_GetError

Thanks for all your help so far everybody.

HunterX

Share on other sites
now you should link to sdl.lib, too..

and then set your app to multithreaded dll, too.. and don''t forget to link to sdlmain.lib, too

If that''s not the help you''re after then you''re going to have to explain the problem better than what you have. - joanusdmentia

davepermen.net

Share on other sites
I know that I''m perhaps asking stupid questions for you guys, but how do I link sdl.lib and multithread dll?

Thanks

Share on other sites
Go to the C/C++ tab, and in that drop down choose Linker settings (or something very close to that). Once you select it, there will be a long textfield with all sorts of files listed like kernel32.lib, and other .lib files. Put opengl32.lib, sdl.lib, and sdlmain.lib in there somewhere.

Alternatively, use the #pragma comment as shown before. I''d recommend against this, personally.

To set it as a multithreaded DLL, goto Project->Settings again.
Go to the C/C++ tab, and choose Runtime Library in the drop down. One of those drop downs will say "Singlethreaded" or something close to that, change it to Multithreaded DLL.

Share on other sites

You might also want to read my Tutorial on setting up for SDL+OpenGL.

Cheers!.

Share on other sites
Looks better now. Now I only have 4 errors left...

Main.obj : error LNK2001: unresolved external symbol _gluPerspective@32

Main.obj : error LNK2001: unresolved external symbol _gluLookAt@72

sdlmain.obj(SDL_main.ojb) : error LNK2001: unresolved external symbol _SDL_main

Debug/Main.exe : fatal error LNK1120: 3 unresolved externals

Share on other sites
Same thing as before, but add glu32.lib to that list of libs.

Share on other sites
When I do all this, I get only 2 errors.

LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

and

Debug\Main.exe : fatal error LNK 2001: 1 unresolved externals

I''m sorry, but I just do not see what is still missing!

Thanks for help and patience.

HunterX

Share on other sites
Do you have a main() function...?

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]

Share on other sites
Yes, I have a int main(void) function...

Share on other sites
quote:
Original post by HunterX
Yes, I have a int main(void) function...

Well, your compiler is under the distinct impression that you don''t....sure you included the file in the project?

Share on other sites
quote:
Original post by HunterX
Yes, I have a int main(void) function...

int main(int argc, char **argv)

Try using this in place of your current int main(void).

Share on other sites
SDL uses its own gl.h file. it should be in your SDL directory the include directory of your compiler. the line to include it is:

#include "sdl/sdl_opengl.h"

#include "gl/gl.h"

*I think*

Also goto the SDL web site and download the manual http://www.libsdl.org/docs.php it has a tutorial on how to set OGL up with SDL.

[edited by - sckoobs on November 11, 2003 11:39:19 AM]