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

Author Topic: static link problem  (Read 911 times)

0 Members and 1 Guest are viewing this topic.

Neurohaox

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
static link problem
« on: June 26, 2018, 09:53:08 am »
First of all hello to everyone.
I'm having issues when trying to static link an example program.

I'm using this version of sfml -> GCC 7.3.0 MinGW (DW2) - 32-bit
and this mingw -> MinGW Builds 7.3.0 (32-bit)

g++ --version output
g++ <i686-posix-dwarf-rev0, Built by MinGW-W64 project> 7.3.0

dir structure:
sfml dir -> C:\sfml\
include dir -> C:\sfml\include
lib dir -> C:\sfml\lib

g++ -c main.cpp -I"C:\sfml\include"
goes fine

g++ main.o -o main.exe -DSFML_STATIC -L"C:\sfml\lib" -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lwinmm -lgdi32
this leaves me with undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale' and bunch of others

Code in question is standard tutorial example
Quote
#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;
}

Can anyone point me what I'm doing wrong?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: static link problem
« Reply #1 on: June 26, 2018, 11:58:38 am »
Where did you download the compiler from?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Neurohaox

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: static link problem
« Reply #3 on: June 26, 2018, 07:48:12 pm »
I'm not 100% sure, but I think the -DSFML_STATIC needs to go on the compile command as it will influence the header, so:

g++ -DSFML_STATIC -c main.cpp -I"C:\sfml\include"
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Neurohaox

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: static link problem
« Reply #4 on: June 26, 2018, 09:08:06 pm »
Ohhhh. Indeed it did worked. Thank you kind sir for your help! And have a nice day!