Skip to content

Instantly share code, notes, and snippets.

@brccabral
Last active April 20, 2022 21:22
Show Gist options
  • Save brccabral/3a2bb2d6f3d704c37c10f56ecd42d65c to your computer and use it in GitHub Desktop.
Save brccabral/3a2bb2d6f3d704c37c10f56ecd42d65c to your computer and use it in GitHub Desktop.
SFML

SFML

Download

  1. Go to SFML GitHub page https://github.com/SFML/SFML
  2. Change the branch to the version you want to build, or keep in master to build most recent
  3. Download the zip file for that branch
  4. Extract any where, I like ~/SFML-versionX

Compile and Install

  1. Open cmake-gui (install with apt install cmake-qt-gui, run with cmake-gui)
  2. Field "Where is the source code": ~/SFML-versionX
  3. Field "WHere to build the binaries": ~/SFML-versionX/build (create if it doesn't exist)
  4. Click Configure
  5. If this is the first time, select generator Unix Makefiles
  6. Options will be red
  7. Change values, like CMAKE_BUILD_TYPE from Release to Debug, and others
  8. Pay attention to CMAKE_INSTALL_PREFIX
  9. Click Configure again, options will be normal
  10. Click Generate
  11. In terminal, cd ~/SFML-versionX/build
  12. make clean
  13. make
  14. sudo make install

Build and Run a project

  1. When executing g++ Linker, make sure to use the CMAKE_INSTALL_PREFIX/lib to do the linking, example:
  • If CMAKE_INSTALL_PREFIX = /usr/local, use -L/usr/local/lib when linking
  • g++ main.o -o final_program -L/usr/local/lib -lsfml-graphics
  • When running, make sure it is in LD_LIBRARY_PATH
  • export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment