SFML community forums

Help => General => Topic started by: kokotoff on January 31, 2024, 04:03:07 pm

Title: SFML on Raspberry Pi?
Post by: kokotoff 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.
Title: Re: SFML on Raspberry Pi?
Post by: eXpl0it3r 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