SFML is a simple to use and portable API written in C++. You can think of it as an object oriented SDL. SFML is made of modules in order to be as useful as possible for everyone. You can use SFML as a minimalist window system in order to use OpenGL, or as a complete multimedia library full of features to build video games or multimedia softwares.
This page provides detailed installation steps. But here i will try to explain.
- Since we are setting up codeblocks download the SFML TDM(SJLJ) version. Download 32 bit if you want maximum support. 32 bits run on both 32 and 64 bit systems.
- Now unzip and keep in your folder of choice. It’s best to use a path like, c:\sfml\
- Go to Settings -> Compiler -> Search Directories -> compiler ( sub tab ) then click Add. Now locate the folder where you unzipped sfml and find the include folder. For example, C:\SFML-2.2\include
- Next goto Linker ( sub tab ) click Add and find the lib folder of unzipped sfml. For example, C:\SFML-2.2\lib
- Now open codeblocks. Go to Settings -> Compiler -> Linker Settings we can see anadd button here. If we click it we are shown .a files.
- File names are prefixed with lib also with .a extension. We do not need that. For example, if the library you want to add is named as, libsfml-graphics.a we can just type in sfml-graphics after clicking on add button. We must omit lib and .a part in the name.
- We also need to maintain order of libraries. For example, we add sfml-graphics, sfml-window, then sfml-system.
- Also if you are wondering what those .a files with -s-d stand for. -s stands for static and -d stands for debug. I’ve setup the version with out static. But if want to use static linkers settings for example, sfml-graphics-s then we need another step. Goto compiler settings tab, then goto #defines sub tab and write the following, SFML_STATIC.
- Now a crucial step when you create a project or a file copy all the dll files located in your unzipped sfml folder bin directory to your executable directory. Means basically copy dll files to where your cpp file is located.
- Now create a cpp file and copy the codes located below this page to your cpp and Run. If it runs then you have successfully setup sfml. Now start creating apps and games. Happy coding 🙂