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
2. Click the download link from the top menu, and then select the latest stable version download for 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:
- 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 your project folder, and move your executable to inside this bin folder.
- g++ -LC:\SFML\lib -o main.exe main.o -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system