1
\$\begingroup\$

I am not sure what to do, I have added the include / lib files in the IDE include / lib folders. But I am getting these errors. Someone please help me! What am I doing wrong? Do I need to add some more code or what?

Errors

Error C1189   #error:  OpenGL header already included, remove this include, glad already 
provides it OpenGLSetup   
c:\program files (x86)\microsoft visual studio 14.0\vc\include\glad.h 26

Error (active)        #error directive: OpenGL header already included, remove 
this include, glad already provides it    OpenGLSetup 
c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\glad.h 26

======

Here is a link to the project on gitub: https://github.com/Kraycon/OpenGLSetup

\$\endgroup\$
4
  • \$\begingroup\$ 1. Code and errors should be shared as text, not as images. This both makes them easier to read, and also searchable so that folks with similar problems / experts with relevant skills can find your question. 2. Did you try removing the redundant include directive as the error message instructed you to, and verifying that the source files it's complaining about are in the indicated folders? \$\endgroup\$
    – DMGregory
    Sep 15, 2017 at 17:12
  • \$\begingroup\$ Hi, I got rid of two errors but I am not sure what is means by remove the include. Where is teh OpenGL include? \$\endgroup\$ Sep 15, 2017 at 17:55
  • \$\begingroup\$ @KrayconStudios "remove" - abolish or get rid of, "include" - (here) A preprocessor in the c++ language that tells the compiler to insert the specified file to the position of the preprocessor statement \$\endgroup\$
    – Bálint
    Sep 15, 2017 at 17:58
  • 1
    \$\begingroup\$ Please include the faulty code into the question: you'll keep on working on your project, fixing your issues. Your linked project will be completely irrelevant to future readers of this site, making this question completely useless for future readers. \$\endgroup\$
    – Vaillancourt
    Sep 15, 2017 at 20:52

2 Answers 2

3
\$\begingroup\$

TL;DR: #define GLFW_INCLUDE_NONE before including GLFW, or include glad bfore including glfw.

When you get these errors, the first thing to do is search for where the message is being generated:

https://github.com/Kraycon/OpenGLSetup/blob/165ff0702f8882bf9e2fda6f3a14fd31a0f03fd6/Include%20Files/glad.h#L25

Okay, so Glad is telling you not to include OpenGL headers yourself because Glad already provides it.

But, uh, you're not including OpenGL ... so something else is including it. Searching for "#include .*gl.h" gets you to

https://github.com/Kraycon/OpenGLSetup/blob/165ff0702f8882bf9e2fda6f3a14fd31a0f03fd6/Include%20Files/glfw3.h#L140

ah, GLFW includes OpenGL/gl.h among a bunch of other opengl-related headers. A look at GLFW's docs (http://www.glfw.org/docs/3.1/build.html) shows

If you are using an OpenGL extension loading library such as glad, the extension loader header should either be included before the GLFW one, or the GLFW_INCLUDE_NONE macro (described below) should be defined.

\$\endgroup\$
0
\$\begingroup\$

The OpenGL header is already included as part of glfw3. Swap the first two lines of your program and pray glfw3 does not care that glad has included the OpenGL header.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .