SFML community forums
Help => General => Topic started by: PhiLLe on May 08, 2011, 09:18:17 pm
-
Hey. I have some problems linking a test .cpp against the static sfml2 libraray with codeblocks.
// No comments on the code please xD
#include <SFML/System.hpp>
int main ()
{
sf::Clock clock;
return clock.GetElapsedTime();
}
I build the SFML2 Lib static and dynamic without any errors with cmake and the mingw32 makefile.
When I link against "libsfml-system-s.a" there is this error:
obj\Release\main.o:main.cpp|| undefined reference to `_imp___ZN2sf5ClockC1Ev'|
obj\Release\main.o:main.cpp|| undefined reference to `_imp___ZNK2sf5Clock14GetElapsedTimeEv'|
||=== Build finished: 2 errors, 0 warnings ===|
When I link against "libsfml-system.a" there is no error. Also the examples work when they are created with the static library. Whats up with that?
-
You must define the SFML_STATIC macro.
-
Thank you!
Wasn't it the other way around in SFML 1.x? That you had to define a DYNAMIC macro? (I'm not sure about it since I never really worked with it)
-
Wasn't it the other way around in SFML 1.x? That you had to define a DYNAMIC macro?
Yes it was ;)
I changed it so that dynamic linking, which is more or less the standard (especially on Linux and OS X), requires no additional configuration.
-
Hi, I also have some problems with compiling SFML2 static libraries.
I hope to not be doing any confusion with terms, what I mean is that I used to link -s files with 1.6 because I didn't want to copy the DLLs in the exe dirs.
Anyway, here's my problem:
I've downloaded the SFML2 tarball from GitiHub then followed this tutorial (http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php) to get Visual C++ 2010 solution files etc.
I set CMake like this and have tried doing everything from scratch with and without FORCE_STATIC_VCRT: http://i.imgur.com/LFbt5.jpg (Actually I did build the examples)
In the output directory there are only the following files:
sfml-*-d-2.dll
sfml-*-d.lib
sfml-*-d.exp
sfml-*-d-2.ilk
sfml-*-d-2.pdb
(and the same as above without -d for Release)
Now, unless I'm mistaken the un-bolded ones are garbage from the compiler and can be ignored.
The problem is that I'm not getting any *-s files to be linked in my projects. If I link normal DLLs the code gets compiled but when I open the executable I get a missing DLL error. Also I have defined SFML_STATIC in my code.
-
I set CMake like this and have tried doing everything from scratch with and without FORCE_STATIC_VCRT
The variable that controls static/dynamic builds is BUILD_SHARED_LIBS, not FORCE_STATIC_VCRT.
If you think it's not clear enough in the tutorial, let me know how I could improve it ;)
-
I set CMake like this and have tried doing everything from scratch with and without FORCE_STATIC_VCRT: http://i.imgur.com/LFbt5.jpg
The variable that controls static/dynamic builds is BUILD_SHARED_LIBS, not FORCE_STATIC_VCRT.
If you think it's not clear enough in the tutorial, let me know how I could improve it ;)
:oops: I understood it while re-reading the tutorial and was going to delete my post.
I think the tutorial is clear enough with this line:
This boolean option controls whether you build the dynamic (shared) libraries of SFML, or the static ones.
it was just me being careless. thanks :oops:
one thing I could add is that in the 2.0 documentation there is the doc for GetEvent but in reality it's called in another way (PoolEvent I think?)
-
one thing I could add is that in the 2.0 documentation there is the doc for GetEvent but in reality it's called in another way (PoolEvent I think?)
Yep, the documentation is not up-to-date. I have to generate it and re-upload it.
You can have an updated version generated if you enable the BUILD_DOC option.