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

Author Topic: Problems with linking SFML2 static  (Read 3254 times)

0 Members and 1 Guest are viewing this topic.

PhiLLe

  • Newbie
  • *
  • Posts: 36
    • View Profile
Problems with linking SFML2 static
« on: May 08, 2011, 09:18:17 pm »
Hey. I have some problems linking a test .cpp against the static sfml2 libraray with codeblocks.

Code: [Select]
// 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:
Quote
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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problems with linking SFML2 static
« Reply #1 on: May 08, 2011, 09:52:39 pm »
You must define the SFML_STATIC macro.
Laurent Gomila - SFML developer

PhiLLe

  • Newbie
  • *
  • Posts: 36
    • View Profile
Problems with linking SFML2 static
« Reply #2 on: May 10, 2011, 02:44:50 pm »
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)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problems with linking SFML2 static
« Reply #3 on: May 10, 2011, 02:50:22 pm »
Quote
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.
Laurent Gomila - SFML developer

Trijames

  • Newbie
  • *
  • Posts: 6
    • View Profile
Problems with linking SFML2 static
« Reply #4 on: May 10, 2011, 04:43:26 pm »
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 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:
Quote
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problems with linking SFML2 static
« Reply #5 on: May 10, 2011, 04:49:01 pm »
Quote
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 ;)
Laurent Gomila - SFML developer

Trijames

  • Newbie
  • *
  • Posts: 6
    • View Profile
Problems with linking SFML2 static
« Reply #6 on: May 10, 2011, 04:51:48 pm »
Quote from: "Laurent"
Quote
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:
Quote
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?)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problems with linking SFML2 static
« Reply #7 on: May 10, 2011, 05:01:56 pm »
Quote
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.
Laurent Gomila - SFML developer

 

anything