SFML community forums
Help => General => Topic started by: 1cubealot on June 18, 2023, 03:05:05 pm
-
Hi.
I am trying to compile just a window program but it hasn't comiled ever. I have a main.cpp file and I have a smfl file which has all the folders in it and I want to know how to build it using g++. I am using sublime text.
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Window");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::Black);
// Draw your SFML objects here
window.display();
}
return 0;
}
-
You link SFML like you would link any other library.
If you don't know how to do that, I recommend to do a bit of research on your own, on how to configure sublime text. Maybe some of the official tutorials for SFML can give you a bit of a hint as well.
You can also use CMake for your build script, then I highly recommend to start with the SFML CMake Template (https://github.com/SFML/cmake-sfml-project).