How to Compile Your Games in SFML with GCC MinGW on Windows
For use with your favorite Code Editor or IDE!
SFML is a great alternative for developing 2D games, in addition to other multimedia resources.
First of all, you must have GCC/G++ with MinGW properly installed on your system, and to do so, if you don’t have it installed yet, just follow the steps in this tutorial:
01. Download SFML for MinGW
After properly installing and running GCC/G++ with MinGW, the next step is to download a different SFML package (different from the Visual Studio version).
And for that, access the downloads page of the SFML website at the link: https://www.sfml-dev.org/download/sfml/2.5.1/ and download the version:
GCC 7.3.0 MinGW (SEH) - 64-bit as shown below:
If you want to download it right here, just click the button below:
02. Extract the file
The downloaded file will have the name and extension:
SFML-2.5.1-windows-gcc-7.3.0-mingw-64-bit.zip, extract this file by right-clicking it and choosing
After extracted there will be a folder named:
SFML-2.5.1, I renamed it to just
It will be easier to use when compiling.
03. Copying files to your project
Now enter this folder (
SFML) and copy all the files that are inside the subfolder:
bin to the “root” of your project and then copy the entire
SFML folder also to the “root” of your project, the files are:
After listing the files with the
lscommand of PowerShell inside my project folder:
In addition to the
SFML folder and the files copied from the
SFML\bin subfolder, there is also the
main.cpp file that contains the code that we are going to compile, if you want to use it as a test, use the code below:
Now let’s compile!
04. Compiled an SFML project with GCC MinGW
To compile, just enter your project through PowerShell or
CMD and run the command:
Note the use of the parameters:
-L(lib) with the respective directories to the
SFML folder that is inside our project. And also the flags:
If you are creating code with Audio and/or Network add the flags:
Now just run the binary and run to the hug: