Windows OpenGL Header Already Included Error, C++

My code is very messy for now, however I cleaned it up some and included the project’s class right in the main document so that it would be easier to spot my problem.

I have simplified everything and I am still getting the error:

C1189 #error: OpenGL header already included, remove this include, glad already provides it

I tried adding : #define GLFW_INCLUDE_NONE, and tried adding this as a preprocessor definitions too. I also tried to change the #ifdef - #endif, except I just couldn’t get it working. The code repository URL is :

The branch is : combine_sources
The Commit ID is: 0b6bc74
The files involved are : shader_class.cpp and glad.h

glad1.cpp was also in my project, I removed it to try to solve this problem.

Thank you, I enjoy OpenGL programming,


To further explain, glad works fine until glew.h is used to allow the following to work:

glColor3f(0, 1, 0.);

After the glew.h is included is when I get the above error.

Could I please have some help?


EDIT : better GitHub id: a4eaf31

Can’t help you with “the solution”, but I remember having trouble with glew and the gl headers too. If I remember correctly glew must always be included before the gl headers. Check this link:

In your original post the error message reads:

C1189 #error: OpenGL header already included, remove this include, glad already provides it

Never used glad but according to this link

it is doing the same stuff as glew (loading OpenGL extensions). So I don’t know if you really need both. Anyways, glew needs to be put in front of the glad headers, since it must be included before gl.h, which is automatically included by glad. However, if glew also includes the gl headers internally, than you have to decide for one of those two libs. This should not be a problem since they are meant to do the same thing as far as I understood it.

ProgrammerX said, “So I don’t know if you really need both,” referring to using two extension managers.

The findings are not only is it, “[uncertainly] not needed,” but they actually won’t work together because they do the same thing.

This is what I learned; one must:

Use only one : glew or glad (also, they do the same thing, extensions.)
Use only one : glfw or glut. (these two also do their own same thing.)

glfw seems to be recommended over glut and if one is removing glut, make sure to remove all of the headers involved with it.

So, I’m new here,