Skip to content
crumblingstatue edited this page Sep 12, 2022 · 8 revisions

Prerequisites

  • git
  • Account with sudo. It is not required but a global install of SFML would make the process a lot easier.

Note

If you have versions lower than 2.4 from apt for example, remove that before installing SFML v2.4.

Installation

If your OS is Archlinux, you can do

sudo pacman -S sfml

for Ubuntu and its derivatives you can do

sudo apt install libsfml-dev

Dependencies

sudo apt-get install build-essential cmake git \
libx11-dev freeglut3-dev libxcb-image0-dev libudev-dev libjpeg8-dev libopenal-dev libsndfile1-dev libfreetype6-dev

SFML

First make a folder to hold all of the files that you are installing.

mkdir sfml
cd sfml

Then clone the latest release of SFML from Github.

git clone https://github.com/SFML/SFML
cd SFML
# Get latest release version (2.5)
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
cd ..

Then install SFML.

cd SFML
cmake .
make all
sudo make install
cd ..

That's it. You now have SFML installed and can now run Rust-SFML.

Common warning messages

//usr/local/lib/libsfml-graphics.so: undefined reference to `__cpu_model'

This is a problem that exists from GCC 5.0 and above. Go to your SFML files, edit src/SFML/Graphics/CMakeLists.txt to have

# ImageLoader.cpp must be compiled with the -fno-strict-aliasing
# when gcc is used; otherwise saving PNGs may crash in stb_image_write
if(SFML_COMPILER_GCC)
    set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
endif()


# NEW CODE BEGINS
if(SFML_COMPILER_GCC AND BUILD_SHARED_LIBS)
    message(WARNING Applying workaround)
    list(APPEND GRAPHICS_EXT_LIBS "-lgcc_s -lgcc")
endif()
# NEW CODE ENDS

References

Clone this wiki locally