SFML community forums
Help => General => Topic started by: Shimajda on March 19, 2010, 06:36:47 pm
-
Hi
I have my library using sfml, and after I use my library in other project it return following error:
C:\*\cppt\consoleApp\libstl.a(CTest.o)||In function `_ZN5CTestC2Ev':|
C:\*\cppt\stl\CTest.cpp|6|undefined reference to `sf::SocketTCP::SocketTCP()'|
C:\*\cppt\stl\CTest.cpp|7|undefined reference to `sf::IPAddress::IPAddress(char const*)'|
C:\*\cppt\stl\CTest.cpp|7|undefined reference to `sf::SocketTCP::Connect(unsigned short, sf::IPAddress const&, float)'|
C:\*\cppt\stl\CTest.cpp|8|undefined reference to `sf::SocketTCP::Close()'|
C:\*\cppt\consoleApp\libstl.a(CTest.o)||In function `_ZN5CTestC1Ev':|
C:\*\cppt\stl\CTest.cpp|6|undefined reference to `sf::SocketTCP::SocketTCP()'|
C:\*\cppt\stl\CTest.cpp|7|undefined reference to `sf::IPAddress::IPAddress(char const*)'|
C:\*\cppt\stl\CTest.cpp|7|undefined reference to `sf::SocketTCP::Connect(unsigned short, sf::IPAddress const&, float)'|
C:\*\cppt\stl\CTest.cpp|8|undefined reference to `sf::SocketTCP::Close()'|
||=== Build finished: 8 errors, 0 warnings ===|
My Code::Blocks project (http://www.sendspace.pl/file/0a1827dd209f612da1df178)
I have -lsfml-network-s in my static library. Nothing changes when I add it to project where I use my library.
For me it looks like sfmllib is not included in my lib.
Help :?:
-
There's no link step when compiling a static library, which means that your -lsfml-network-s is ignored. Linking is done only when building a binary (a dynamic library or an executable), so you have to link to sfml-network in your final project.
There is a workaround (that is used for SFML static libraries) which involves using the ar command to manually add the external dependencies to a static library (static libraries are just archives of compiled files).
-
Thanks i have used ar to add external dependencies to my static library and it works:
ar rcs my_library.a *.o
Tutorial says that libraries have to be linked in the right order. How it will work if I make one library from sfml-graphics sfml-window and sfml-system?
-
How it will work if I make one library from sfml-graphics sfml-window and sfml-system?
It should be ok.