Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Can not compile SFML example Program statically  (Read 1148 times)

0 Members and 1 Guest are viewing this topic.

gomfol12

  • Guest
Can not compile SFML example Program statically
« on: March 29, 2020, 10:12:48 pm »
Hey,

firstly sorry for the bad english

OS: Windows
Compiler: tdm-gcc
SFML compiled with this compiler

When i try to run the compile command:
g++ main.cpp -Isfml/include -Lsfml/lib -lsfml-graphics-s -DSTATIC_SFML

It gives me error messages like:
undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
 
several times

this is the code:
#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;
}

I hope someone can help me.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Can not compile SFML example Program statically
« Reply #1 on: March 30, 2020, 08:23:58 am »
As the official tutorial state, you need to link all the required SFML libraries. sfml-graphics depends on sfml-window and sfml-system, plus when you're linking SFML statically, you also need to link all of SFML's dependencies.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

gomfol12

  • Guest
Re: Can not compile SFML example Program statically
« Reply #2 on: March 30, 2020, 11:54:25 am »
Thank you for the fast reply.
I changed the command and it worked.

command:
g++ main.cpp -Isfml/include -Lsfml/lib -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -DSFML_STATIC

 

anything