- Download SFML source code from https://www.sfml-dev.org/download.php
- Download CMake from https://cmake.org/download/
- Open CMake GUI.
- Enter source code path to CMake (C:/libs/src/SFML-2.5.1).
- Enter build path to CMake (C:/libs/src/SFML-2.5.1/build).
- Press Configure and select
MinGW Makefiles
andUse default native compilers
. - Now you have SFML-2.5.1/build folder and makefile in there, open terminal inside the new build folder and type:
mingw32-make
. - Now inside SFML-2.5.1/build/lib you will have compiled static and dynamic library files which you can use in your project.
- Create new project folder.
- Create
main.cpp
. - Create
include
folder inside the project folder. - From SFML/include copy the containing SFML folder into your projectfolder/include (so that your project will have include/SFML).
- From SFML/build/lib copy the .dll files to your project root folder so that they are on same level as your compiled executable.
- Put this code in your main.cpp:
#include "include/SFML/Graphics.hpp"
// NOTICE DOUBLE QUOTES INSTEAD OF <> SINCE WE HAVE HEADER FILES INSIDE THE PROJECT FOLDER.
int main()
{
sf::RenderWindow window(sf::VideoMode(512, 512), "SFML");
// circle
sf::CircleShape shape(50.f);
shape.setFillColor(sf::Color(150, 50, 250));
shape.setOutlineThickness(10.f);
shape.setOutlineColor(sf::Color(250, 150, 100));
// point
sf::Vertex point(sf::Vector2f(200, 200), sf::Color::White);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::Black);
window.draw(shape);
window.draw(&point, 1, sf::Points);
window.display();
}
return 0;
}
Compile your main.cpp with example this kind of command:
g++ -std=c++11 main.cpp -o main.exe -I include -L . -lsfml-system-2 -lsfml-window-2 -lsfml-graphics-2
Press Configure and select MinGW Makefiles and Use default native compilers.
after this u need to press generate(in cmake)!!!!