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

Author Topic: Confused about static linking  (Read 8240 times)

0 Members and 1 Guest are viewing this topic.

phoekz

  • Newbie
  • *
  • Posts: 14
    • View Profile
Confused about static linking
« on: June 23, 2011, 11:36:41 pm »
I am currently trying to accomplish this wonderful thing called static linking and I have no idea how this is done. I downloaded newest src of SFML 2.0 and ran Cmake with it. Then I ticked STATIC_STD_LIBS and pressed Generate. After that I have no clue how to proceed. Do I have to do something before I build SFML in Visual C++ 2010 and what do I have to do in project itself to enable static linking?

I've been trying something myself like messing with build options and adding SFML_STATIC on preprocessor, but I am still very confused how to get this work properly.

I'd love to hear how you guys do it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Confused about static linking
« Reply #1 on: June 24, 2011, 07:37:35 am »
What kind of static linkinkg are you talking about?

- Building and using SFML static libs: everything's explained in the tutorial, especially the CMake options that you need (and the ones that you don't need)

- Using the standard libraries statically: it's also explained in the tutorial, except how to configure your own project to use them as well
Laurent Gomila - SFML developer

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Confused about static linking
« Reply #2 on: June 24, 2011, 08:22:14 am »
Quote from: "phoekz"
I've been trying something myself like messing with build options and adding SFML_STATIC on preprocessor, but I am still very confused how to get this work properly.



If you are using Visual Studio:
http://www.sfml-dev.org/forum/viewtopic.php?p=33608#33608

phoekz

  • Newbie
  • *
  • Posts: 14
    • View Profile
Confused about static linking
« Reply #3 on: June 24, 2011, 12:10:47 pm »
Well this is how I've been trying to do it:

1. Get newest snapshot from Github
2. Run Cmake on it, unticking BUILD_SHARED_LIBS and ticking STATIC_STD_LIBS
3. Open .sln file with Visual Studio
4. Run build on ALL_BUILD and it results -d libraries only :( (if release then there is no -d, but are still dyn linked).

I believe I missed something here in build options and thats the part where I'm confused.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Confused about static linking
« Reply #4 on: June 24, 2011, 01:18:40 pm »
Quote from: "phoekz"
2. Run Cmake on it, unticking BUILD_SHARED_LIBS and ticking STATIC_STD_LIBS
As Laurent stated, these are independent and different options.

STATIC_STD_LIBS enabled links statically to the CRT libraries (C Runtime and standard library). Your own project's CRT linkage must be the same as SFML's one. By default, this option is disabled, and you don't have to care about configuring your own project.

BUILD_SHARED_LIBS enabled means that the SFML libraries are linked dynamically. This influences whether you link to the static SFML libraries (using the "-s" postfix and defining SFML_STATIC) or the dynamic ones.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything