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

Author Topic: Question about SFML_USE_STATIC_STD_LIBS  (Read 2156 times)

0 Members and 1 Guest are viewing this topic.

mach990

  • Newbie
  • *
  • Posts: 1
    • View Profile
Question about SFML_USE_STATIC_STD_LIBS
« on: October 21, 2013, 04:02:11 am »
Hey everyone,

I was originally going to post a question about why my configuration wasn't building the appropriate static libraries, but apparently now it is magically working.  I think CMake screwed something up, but anyways... it's working now.

I'm just a little confused, conceptually, about static libraries in general.  I have googled around quite a bit.

I used to use sfml in a "static" configuration, so I didn't have to distribute any dll's with the executable.  But that was with the BUILD_SHARED_LIBS option, which created what I thought were static libraries.  Now, I'm using USE_STATIC_STD_LIBS... Both of these are static libraries, right?  I guess I'm not *too* familiar with how the linker works, but are the differences between the two just that the former does not statically link the C runtime?

The entire reason I moved to static_std_libs is because CryptoPP recommends using their library in a static configuration, which I believe means everything must be static. 

I guess I'm not even sure what my question is!  Is the first static version of SFML statically linked to my application and dynamically linked to the C Runtime, and the second is statically linked to both?  I need the second configuration if another library (cryptoPP) is statically linking to the C Runtime, right?  I imagine that's the case, unless I somehow am running two separate heaps at the same time for each runtime, which seems to make no sense.

Any clarification would be appreciated.  I tried to do as much research as I could before posting!

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Question about SFML_USE_STATIC_STD_LIBS
« Reply #1 on: October 21, 2013, 04:18:05 am »
If you read the CMake tutorial, it'll tell you that BUILD_SHARED_LIBS on means dynamic linking, and BUILD_SHARED_LIBS off means static linking.

I believe how you choose to link the standard C++ library is an entirely separate parameter.  Of course, you can't call static libs from dynamic ones, so you can't have a static standard library and dynamic SFML, but the other permutations should all work.

However, statically linking the standard library is the sort of thing you shouldn't do unless you really know what you're doing.  I hear it can sometimes make a program more cross-platform/compatible, but it's just as likely to cause other problems, so stick to the default dynamic linking for that one.

I know nothing about CryptoPP so that's probably the limit of what I can tell you right now.  Any idea why it needs a static standard lib?
« Last Edit: October 21, 2013, 04:21:00 am by Ixrec »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Question about SFML_USE_STATIC_STD_LIBS
« Reply #2 on: October 21, 2013, 07:48:17 am »
Quote
Of course, you can't call static libs from dynamic ones, so you can't have a static standard library and dynamic SFML
What? Of course you can do that :P

Quote
The entire reason I moved to static_std_libs is because CryptoPP recommends using their library in a static configuration, which I believe means everything must be static.
I would be suprised if it was was they really meant. They probably just mean that CryptoPP should be linked statically.

The standard library has to be linked the same way by all the libraries used in a program, otherwise bad things may happen. So don't change it to static (dynamically linking the standard libs is usually the default option) unless you have very good reasons.
Laurent Gomila - SFML developer

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Question about SFML_USE_STATIC_STD_LIBS
« Reply #3 on: October 21, 2013, 08:37:16 am »
Quote
Of course, you can't call static libs from dynamic ones, so you can't have a static standard library and dynamic SFML
What? Of course you can do that :P

Edit: Now that I think about it, I wasn't recompiling the dynamic library when I tried that, so my bad.
« Last Edit: October 21, 2013, 08:41:53 am by Ixrec »

 

anything