SFML community forums

General => General discussions => Topic started by: phoekz on June 23, 2011, 11:36:41 pm

Title: Confused about static linking
Post by: phoekz 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.
Title: Confused about static linking
Post by: Laurent 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
Title: Re: Confused about static linking
Post by: Cuban-Pete 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
Title: Confused about static linking
Post by: phoekz 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.
Title: Confused about static linking
Post by: Nexus 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.