I use Siblime Text 4 with CMD. If you work on Windows you can install MinGW and build SFML with CMake GUI (or with the console version of CMake). Create a file with the "makefile" name and copy the content below to "makefile". This example shows how to include a few libraries like SFML, FMOD (for sounds), and Box2D (for physics, collision detection, ray casting and so on). To build the next example to EXE you should type the "mingw32-make" command in CMD.
makefile
CC = g++
INC = -I"E:\Libs\SFML-2.5.1-windows-gcc-7.3.0-mingw-64-bit\include" \
-I"E:\Libs\box2d-2.4.1-mingw-64-bit\include" \
-I"C:\Program Files\FMOD SoundSystem\FMOD Studio API Windows\api\core\inc"
LIB = -L"E:\Libs\SFML-2.5.1-windows-gcc-7.3.0-mingw-64-bit\lib" \
-L"E:\Libs\box2d-2.4.1-mingw-64-bit\lib"
FLAGS = -c -DSFML_STATIC
all: main.o
$(CC) main.o $(LIB) -static \
"C:\Program Files\FMOD SoundSystem\FMOD Studio API Windows\api\core\lib\x64\fmod.dll" \
-lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lfreetype \
-lopengl32 -lwinmm -lgdi32 -lbox2d -o app
main.o: main.cpp
$(CC) $(FLAGS) $(INC) main.cpp
main.cpp
#include <iostream>
#include <SFML/Graphics.hpp>
#include <box2d/box2d.h>
#include <fmod.h>
b2Vec2 gravity(0.0f, 9.8f);
b2World world(gravity);
FMOD_SYSTEM *m_pSystem;
FMOD_SOUND *m_pSound;
int main()
{
// Print the gravity
std::cout << gravity.y << std::endl;
FMOD_System_Create(&m_pSystem, FMOD_VERSION);
FMOD_System_Init(m_pSystem, 32, FMOD_INIT_NORMAL, 0);
FMOD_System_CreateSound(m_pSystem, "sounds/gamestart.ogg", FMOD_LOOP_OFF | FMOD_2D, 0, &m_pSound);
FMOD_System_PlaySound(m_pSystem, m_pSound, 0, false, 0);
sf::RenderWindow window(sf::VideoMode(240, 240), "SFML works!");
sf::CircleShape shape(120.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}