Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML on Raspberry Pi?  (Read 195 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
    • View Profile
SFML on Raspberry Pi?
« on: January 31, 2024, 04:03:07 pm »
Hi, I work on Raspberry Pi 4, with latest Raspbian.
I downloaded SFML by sudo apt-get xxxx and I try to compile my code C++ with SFML.

g++ -o main main.cpp -lpigpio -Ipigpio -Isfml -lsfml-graphics -lsfml-window -lsfml-system
sudo ./main

Compilation looks fine, executable file is always created, BUT sudo ./main tells me always
error: XDG_RUNTIME_DIR is invalid or not set in the environment. When I try to create window.

My code:

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

int main(){
   sf::RenderWindow window(sf::VideoMode(200, 200), "WORKS!");

Can you help me? If I comment out this RenderWindow function, it works fine.


  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: SFML on Raspberry Pi?
« Reply #1 on: January 31, 2024, 04:11:38 pm »
Entering the error message into a web search lead me to: https://askubuntu.com/questions/456689/error-xdg-runtime-dir-not-set-in-the-environment-when-attempting-to-run-naut

Maybe you need to first correctly configure your xserver or similar.

Not sure what flags were used to build the SFML in to package manager, if you build from source, you could also enable DRM support if you don't want to use X11
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
Dev Blog: https://duerrenberger.dev/blog/