Install CSFML, SFML for C Language

Create 2D games quickly and easily!

Install CSFML, SFML for C Language

CSFML is an interface of SFML for the C Language, because SFML only works natively in C++.

It is available for Windows, GNU/Linux and macOS.

The good thing about having CSFML also installed on your system is that several other programming languages that have bindings for SFML, use CSFML as a wrapper instead of SFML itself.


Example on Ubuntu:

sudo apt install libcsfml-graphics2.5 libcsfml-audio2.5 libcsfml-dev libcsfml-doc libcsfml-network2.5 libcsfml-system2.5 libcsfml-window2.5

If you want to install everything at once:

sudo apt install libcsfml-*

See here for Arch Linux and here for Fedora. For other distros use your system’s package manager search!

For Windows you must download this link, unzip and move to the C:\ drive, another alternative is also to use NuGet :

dotnet add package CSFML --version 2.5.1

There is also a download for macOS, however, you can also use Brew, to do this just run the command:

brew install csfml

You can also compile from scratch, but remember that you must first have SFML installed as a dependency. To do this, run the commands below:

git clone
cmake -B build .
cd build && make
sudo make install
cd ../..
rm -rf CSFML

Basic example code

Create an example file: main.c:

#include <SFML/Graphics.h>

int main(int argc, char **argv) {
   sfVideoMode mode = {800, 450, 32};
   sfRenderWindow *window = sfRenderWindow_create(mode, "CSFML Example", sfResize | sfClose, NULL);

   sfRectangleShape *shape = sfRectangleShape_create();
   sfVector2f vf = {200, 200}, pos = {30, 30};
   sfRectangleShape_setSize(shape, vf);
   sfRectangleShape_setFillColor(shape, sfGreen);
   sfRectangleShape_setPosition(shape, pos);

   while (sfRenderWindow_isOpen(window)) {
     sfEvent event;
     while (sfRenderWindow_pollEvent(window, &event)) {
       if (event.type == sfEvtClosed) {

     sfRenderWindow_clear(window, sfBlack);
     sfRenderWindow_drawRectangleShape(window, shape, NULL);


   return 0;

To compile:

gcc main.c -lcsfml-window -lcsfml-system -lcsfml-graphics

NOTE: If you compiled from scratch and encountered an error when running the binary that is looking for file: .so, then you will need to add the path that was installed to your $LD_LIBRARY_PATH variable:

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"

You can add this line to your ~/.bashrc to automate this addition and not need to run this command every time you run CSFML binaries!

The names of the functions and how to use them are very intuitive, because if you already know SFML it is easy to deduce.

For more information visit the links:

clanguage sfml gamedev