Note: Tested on Windows 10 and Windows 11
This is the starter template and guide to set up SFML on Windows with MinGW and Visual Studio Code.
We didn't find any useful articles or YouTube videos so we tried to set up the project on my own
In this folder, you put all your images animation, and sound.
In this folder all the build file and SFML dlls are stored you can execute the main exe from here.
This folder contains sfml headers and user can create their own headers file too. but you need to make changes to the Makefile.
This is the source file where you write and structure your code.
Here, it is only the starter code you can link the source file from src.
Note: Change makefile as you need. This makefile is not suitable for larger project.
all: compile link
compile:
g++ -Iheaders/sfml/include -c main.cpp
link:
g++ main.o -o main -Lheaders/sfml/lib -lsfml-graphics -lsfml-window -lsfml-system -lopengl32 -lsfml-audio
main
In case the MakeFile is not working, you can manually type the following command to build.
g++ -Iheaders/sfml/include -c main.cpp
g++ main.o -o main -Lheaders/sfml/lib -lsfml-graphics -lsfml-window -lsfml-system -lopengl32 -lsfml-audio
.\main
If ./main dosen't work try /main or main on terminal
If, you are using a Windows Machine, you can directly run the bat file for building project.
echo Building project
g++ -Iheaders/sfml/include -c main.cpp
g++ main.o -o main -Lheaders/sfml/lib -lsfml-graphics -lsfml-window -lsfml-system -lopengl32 -lsfml-audio
main
Download and install vs code from code.visualstudio.com and install the C/C++ extension.
Download and install MinGW from mingw-w64.org or sourceforge.net (We recommend msys2 as it makes things a lot easier). You can find on msys2 website to install it.
Download sfml from sfml-dev.org website and MinGW. You can choose 32-bit or 64-bit version depending upon your platform.
Now structure the file system as below and you are good to go.
Use this command on the terminal.
mingw32-make -f MakeFile
.\run.bat