SFML for Codeblocks Setup Tutorial

What is SFML?

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.

Homepage: http://www.sfml-dev.org/


This page provides detailed installation steps. But here i will try to explain.

  1. 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.
  2. Now unzip and keep in your folder of choice. It’s best to use a path like, c:\sfml\
  3. 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 

    compiler settings
    compiler settings
  4. Next goto Linker ( sub tab ) click Add and find the lib folder of unzipped sfml. For example, C:\SFML-2.2\lib

    linker lib
    linker lib
  5. Now open codeblocks. Go to Settings -> Compiler -> Linker Settings we can see anadd button here. If we click it we are shown .a files.

    linker settings
    linker settings
  6. 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.
  7. We also need to maintain order of libraries. For example, we add sfml-graphics, sfml-window, then sfml-system.
  8. 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.
  9. 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. 

    add dll to cpp location
    add dll to cpp location
  10. 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 🙂


One thought on “SFML for Codeblocks Setup Tutorial

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s