Fatal error: SFML/Graphics.hpp: no such file or directory exists

Lucas Davis picture Lucas Davis · Oct 12, 2015 · Viewed 22.5k times · Source

I'm running into problem after problem with SFML, but hopefully it will be worth it in the end.

Here's the error:

fatal error: SFML/Graphics.hpp : No such file or directory

and the code:

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

int main(){
sf::RenderWindow Window;
Window.create(sf::VideoMode(800, 600), "SFML");

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

Answer

emlai picture emlai · Oct 12, 2015

You need to tell the compiler where to look for the SFML header files. This can be done by passing the -I flag in the compiler invocation:

-I/path/to/SFML/headers