OpenGL and Visual Studio .NET

When using the 2 includes that I need for a program, (gl.h, and glu.h) stops compiling with 102 errors in gl.h. What is the deal? Has anyone encountered this, and how can I fix it. Thanks!

Have you linked the necessary DLLs? That could be your problem. In Visual Studio .NET you have to goto project properties and goto link and type the names of the *.dll files.

#include <windows.h> before <GL/gl.h>

For OpenGL you should be linking to .lib files, not the .DLL files.

You say the errors are in gl.h, so I’m guessing what you probably didn’t do is to #include <windows.h> BEFORE #include <GL/gl.h>. Windows.h contains some #defined stuff that is used in gl.h.

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

#pragma comment (lib, “opengl32”)
#pragma comment (lib, “glu32”)
#pragma comment (lib, “glaux”)

This code will take care of loading the header files AND linking the libraries. If this doesn’t work, then something else is wrong. Maybe you are missing a ‘}’ or a ‘;’ somewhere. Look at the first few errors that come up. Those are usualy indicative of the real error that causes problems. If what i put in for ya isn’t the solution, can you post a few of the errors that you are getting?

  • Halcyon

Thanks, that helped. It now compiles correctly.