How to Install SFML for Windows

How to Install SFML for Windows

In this article, we'll cover how to install the Simple and Fast Multimedia Library (SFML) for C++ projects for Windows. If you'd like to SFML for Mac, please see this article instead: How to Install SFML for Mac


Installing SFML

1. Navigate to the SFML website at https://www.sfml-dev.org/

2. Click the download link from the top menu, and then select the latest stable version download for SFML.



3. On the Download page, locate the version of SFML that matches your compiler and click on the download button. This will likely be either the 32 or 64 bit MinGW - but note you MUST install the correct version of MinGW as well (https://sourceforge.net/projects/mingw/files/latest/download)!


4. Once downloaded, unzip the file.
5. Rename the unzipped folder "SFML" and move it to the main C:\ drive folder.
6. Once that’s done, you’ve successfully installed SFML! You should be able to #include any SFML module in your projects now.

Compiling with SFML

When compiling C++ code using SFML, we need to tell the compiler where to find the SFML libraries as well as manually link the library of each module that we need. As we will ultimately need Graphics, Audio, Window, and System, we may as well link them all now by running the command:

  1. g++ -IC:\SFML\include -c main.cpp -o main.o

This links all of the include files and creates the main.o file. Before running the program, you're going to need to put the executable in a folder with the SFML dynamic libraries (DLLs). So, copy the bin folder from the SFML installation folder to inside your project and move your executable to inside this bin folder.

Last, we want to link all of the library files and create the executable file. Do so with this command:
  1. g++ -LC:\SFML\lib -o main.exe main.o -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system

    • Related Articles

    • How to Install SFML for Mac

      In this article, we'll cover how to install the Simple and Fast Multimedia Library (SFML) for C++ projects for Mac. If you'd like to SFML for Windows, please see this article instead: How to Install SFML for Windows Installing SFML 1. Navigate to the ...
    • How to Install Python on Windows

      If you intend to use our Python courses with a code editor like Python's build-in IDLE, Visual Studio, Anaconda, Spyder, or something else, you will need to first install the Python runtime to your local computer. This short article will cover how to ...
    • How to Install Android Studio on Windows

      This article will cover how to install Android Studio for Windows. For installation on macOS, we recommend checking out this article instead: How to Install Android Studio on Mac Download Android Studio 1. Head to the Android developers website ...
    • How to Install Visual Studio Code for Windows

      In this article, we'll showcase how to install Visual Studio Code (VSC), a multi-language applicable code editor, for Windows. If you'd like to install VSC for Mac, see this article instead: How to Install Visual Studio Code for Mac Installing VSC ...
    • How to Install Android Studio on Mac

      This article will cover how to install Android Studio for macOS. For installation on Windows, we recommend checking out this article instead: How to Install Android Studio on Windows Download Android Studio 1. Head to the Android developers website ...