Jump to content
  • Advertisement
Sign in to follow this  
Jaay_

OpenGL SFML errors when compiling if OpenGL.hpp is included

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I've been having this error for a couple days and I can't find a way to fix it. If I include SFML/OpenGL.hpp during the build it says this:

c:\mingw\include\sfml\opengl.hpp:46:23: fatal error: GL/gl.h: No such file or directory

I'm using MinGW on windows, my IDE is CLion and CLion uses CMake.

Here's the full error log:

Scanning dependencies of target LearningOpenGL
[ 50%] Building CXX object CMakeFiles/LearningOpenGL.dir/src/main.cpp.obj
In file included from C:\My\folder\path\src\main.cpp:4:0:
c:\mingw\include\sfml\opengl.hpp:46:23: fatal error: GL/gl.h: No such file or directory
compilation terminated.
mingw32-make.exe[3]: *** [CMakeFiles/LearningOpenGL.dir/src/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/LearningOpenGL.dir/all] Error 2
CMakeFiles\LearningOpenGL.dir\build.make:62: recipe for target 'CMakeFiles/LearningOpenGL.dir/src/main.cpp.obj' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/LearningOpenGL.dir/all' failed
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/LearningOpenGL.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/LearningOpenGL.dir/rule] Error 2
mingw32-make.exe: *** [LearningOpenGL] Error 2
Makefile:117: recipe for target 'LearningOpenGL' failed

And here's my code:

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>

int main()
{
    sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));

    while (window.isOpen())
    {
        sf::Event event;

        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
    }

    return 0;
}

P.S. It works fine when SFML/OpenGL.hpp isn't included.

Edited by Jaay_

Share this post


Link to post
Share on other sites
Advertisement

I'm not really familiar with SFML but, it appear that "SFML/OpenGL.hpp" is trying to include "gl/gl.h" and you don't have that file.

Have you checked if you have a "gl" folder in your include directory with the "gl.h" file in it?

 

The reason your app compiles without the including OpenGL.hpp may be because you don't make any calls to OpenGL in your application. But, I fear that when you do, it will stop compiling.

 

Again, not sure if that's the case, but it's worth a shot.

 

Hope it helps.

Share this post


Link to post
Share on other sites

P.S. It works fine when SFML/OpenGL.hpp isn't included.

 

Do you plan to do OpenGL with SFML ?

 

I think this is the main question. If you plan to do so, then this page will certainly be helpful.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!