Advertisement

SFML errors when compiling if OpenGL.hpp is included

Started by September 10, 2016 10:13 PM
0 comments, last by Nanoha 8 years, 2 months ago

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.

your problem seems to be this:

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

I'm not sure what the process is to get the GL headers/libraries on Windows. I don't recall having to do anything at all, it just worked but that's with using Visual Studio. Apparently they come as part of the Window's SDK. Check you actually have them on your computer and if you do then you need to tell CLion where to find them (I am not familiar with how you'd do that). If they are not present on your computer then you need to get them, again I am not familiar with that either but this page may be of some use https://www.opengl.org/wiki/Getting_Started#Downloading_OpenGL.

Hopefully this will give you some place to start.

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

This topic is closed to new replies.

Advertisement