Home > Net >  Compile error in SFML 2.5.1 sample code in Linux
Compile error in SFML 2.5.1 sample code in Linux

Time:09-12

Compile error

I was looking at a configuration video in yt for linux mint but it doesn't give me the same results in arch.

    #include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.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;
}

CodePudding user response:

As the error message indicate, there is no constructor for sf::VideoMode which takes two int input for width and height. The constructor expect an argument of type Vector2u.

Create the Window as follows:

sf::RenderWindow window(sf::VideoMode({200, 200}), "SFML works!");
  • Related