Welcome, Guest. Please login or register.

Author Topic: Problens to use network of sfml2  (Read 3849 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 41
    • View Profile
Problens to use network of sfml2
« on: July 11, 2012, 09:52:13 pm »
I made de static compilation of the sfml2 with cmake and mingw. It's working well for graphics, open windows, handle events... but when I try to use network I'm get this errors:

My test code:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>

#include <SFML/Network.hpp>

sf::TcpSocket sock;

int main() {
    sf::RenderWindow wnd;

    return 0;

Code blocks errors:
F:\sfml2\lib/libsfml-network-s.a(Packet.cpp.obj):Packet.cpp:(.text+0x779): undefined reference to `sf::String::clear()'
F:\sfml2\lib/libsfml-network-s.a(Packet.cpp.obj):Packet.cpp:(.text+0x804): undefined reference to `sf::String::String(unsigned int)'

F:\sfml2\lib/libsfml-network-s.a(Packet.cpp.obj):Packet.cpp:(.text+0x81d): undefined reference to `sf::String::operator+=(sf::String const&)'
F:\sfml2\lib/libsfml-network-s.a(Packet.cpp.obj):Packet.cpp:(.text+0x87d): undefined reference to `sf::String::clear()'

F:\sfml2\lib/libsfml-network-s.a(Packet.cpp.obj):Packet.cpp:(.text+0xf4b): undefined reference to `sf::String::getSize() const'
F:\sfml2\lib/libsfml-network-s.a(Packet.cpp.obj):Packet.cpp:(.text+0xf9f): undefined reference to `sf::String::begin() const'

F:\sfml2\lib/libsfml-network-s.a(Packet.cpp.obj):Packet.cpp:(.text+0xfba): undefined reference to `sf::String::end() const'

Maybe someone can help me. Thanks!


  • SFML Team
  • Hero Member
  • *****
  • Posts: 1360
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Problens to use network of sfml2
« Reply #1 on: July 11, 2012, 11:44:09 pm »
I assume you included the needed libraries. You however probably didn't know you need to include them in a specific order.

Simply put each library has a shopping list of functions it needs from other libraries. Every time it needs a new function it adds it to the list. When it goes over a library it puts the functions on the list into the shopping basket. Now imagine if you put something onto the list after you already passed by the library that provides it? It doesn't get put into the basket because you can't turn around :P As a rule of thumb, you must always specify libraries with the most dependencies at the beginning of the list and libraries with the least dependencies at the end.

You could imagine it as an invisible "depends on the following libraries" in between each library in the list:

sfml-graphics depends on the following libraries sfml-window depends on the following libraries sfml-system depends on the following libraries glu32 .....

When you use sfml-network, you find out it is missing the definition of sf::String stuff as seen in the error messages. Where is sf::String stuff defined? The documentation says in sfml-system. Because of this sfml-network must be linked before sfml-system so the list will look like:

sfml-network depends on the following libraries sfml-graphics depends on the following libraries sfml-window ...

I just typed all of that so you know for future libraries you might use. For SFML just remember this order if you use everything:


It works for me all the time.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).


  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Problens to use network of sfml2
« Reply #2 on: July 12, 2012, 02:09:14 am »
Very thanks man! Now it's working!