Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

sfml

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();
    }
}
}
like image 277
Lucas Davis Avatar asked Oct 25 '25 04:10

Lucas Davis


2 Answers

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
like image 73
emlai Avatar answered Oct 26 '25 17:10

emlai


If you're on Linux then this one liner is the way to go:

sudo apt-get install libsfml-dev

Found it in the docs here: https://www.sfml-dev.org/tutorials/2.1/start-linux.php

like image 23
veich Avatar answered Oct 26 '25 17:10

veich