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

Author Topic: Installing SFML on linux  (Read 1199 times)

0 Members and 1 Guest are viewing this topic.

Czarniecki

  • Newbie
  • *
  • Posts: 7
    • View Profile
Installing SFML on linux
« on: February 08, 2022, 11:54:16 am »
I've been developing my game in SFML on windows, but wanted to move to linux. I installed SFML like so:
Quote
sudo apt-get install libsfml-dev
Quote
But when i want to build my program i get:
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake:139 (message):
  Requested SFML configuration (Static) was not found
Call Stack (most recent call first):
  CMakeLists.txt:11 (find_package)


CMake Error at CMakeLists.txt:11 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.
I am using clion and cmake.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10194
    • View Profile
    • development blog
    • Email
Re: Installing SFML on linux
« Reply #1 on: February 08, 2022, 12:20:45 pm »
Don't request static libraries.
The Linux eco system is built on shared libraries, thus you'll also only get shared libraries from the package managers
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Czarniecki

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Installing SFML on linux
« Reply #2 on: February 08, 2022, 12:26:45 pm »
Don't request static libraries.
The Linux eco system is built on shared libraries, thus you'll also only get shared libraries from the package managers
What should i do then?
When i set it to:
Quote
set(SFML_STATIC_LIBRARIES FALSE)
i get:
Quote
In file included from /home/student/CLionProjects/oop21_ww2_14/BerryGame/include/Enemy.h:5,
                 from /home/student/CLionProjects/oop21_ww2_14/BerryGame/include/MrStrawberry.h:4,
                 from /home/student/CLionProjects/oop21_ww2_14/BerryGame/main.cpp:2:
/home/student/CLionProjects/oop21_ww2_14/BerryGame/include/Animation.h:4:10: fatal error: SFML\Graphics.hpp: No such file or directory
    4 | #include <SFML\Graphics.hpp>

Czarniecki

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Installing SFML on linux
« Reply #3 on: February 08, 2022, 01:24:57 pm »
Don't request static libraries.
The Linux eco system is built on shared libraries, thus you'll also only get shared libraries from the package managers

I have my cmakelist like this:
Quote
cmake_minimum_required(VERSION 3.20)
project(BerryGame)

set(CMAKE_CXX_STANDARD 14)

add_executable(BerryGame main.cpp src/Level.cpp include/Level.h src/Game.cpp include/Game.h src/Platform.cpp include/Platform.h src/Item.cpp include/Item.h src/Life.cpp include/Life.h src/Coin.cpp include/Coin.h src/Collider.cpp include/Collider.h src/Enemy.cpp include/Enemy.h src/MrStrawberry.cpp include/MrStrawberry.h src/Animation.cpp include/Animation.h src/MrBerry.cpp include/MrBerry.h src/Projectile.cpp include/Projectile.h src/Sentry.cpp include/Sentry.h)




target_include_directories(BerryGame PUBLIC include)
find_package(SFML 2.4 COMPONENTS graphics window system REQUIRED)


target_link_libraries(BerryGame sfml-system sfml-window sfml-graphics sfml-audio)
And the same fatal error occurs. Funnily enough, when i use this exact cmakelist (with changed executables of course) in this examplary program:
#include <SFML/Graphics.hpp>

int main() {

    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.clear();
        window.draw(shape);
        window.display();
    }
    return 0;
}
It works perfectly fine.

Czarniecki

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Installing SFML on linux
« Reply #4 on: February 08, 2022, 02:49:24 pm »
The problem was that in one file ("Animation.h") SFML/Graphics.hpp was included with backslash, instead of forward slash (apparently debian doesn't allow that, opposite to windows).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10194
    • View Profile
    • development blog
    • Email
Re: Installing SFML on linux
« Reply #5 on: February 09, 2022, 08:57:49 am »
You should always use forward slashes for includes. While Windows default path separator is a backward slash, it also supports forward slashes. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/