SFML community forums

Help => General => Topic started by: JTeck on April 09, 2014, 11:35:04 am

Title: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 11:35:04 am
Hi all,

Does anybody know where I can find the Static DLLS for SFML 2.1? I have done searching on the forums and cant really find anything about where they are found.

Can anybody tell me where/how to get them?

Cheers
Title: Re: How to find the Static DLL's?
Post by: Nexus on April 09, 2014, 11:46:12 am
Static DLLs? DLL stands for Dynamic Link Library ???

Do you mean import libraries? Have you looked at the download page?
Title: Re: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 12:07:09 pm
Static DLLs? DLL stands for Dynamic Link Library ???

Do you mean import libraries? Have you looked at the download page?

I mean, to compile in SFML_STATIC I need Static Library's, but I can't find the sfml-graphics-s-d.dll file anywhere for any module.
Title: Re: How to find the Static DLL's?
Post by: Laurent on April 09, 2014, 12:09:14 pm
Because it is static, a static library has no DLL. Instead of being in a separate DLL in case of dynamic linking, the SFML code will be integrated directly into your executable if you link the static libraries.

If you were searching the DLLs, what did you think the static version of SFML was, compared to the dynamic one? ;)
Title: Re: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 12:15:54 pm
Because it is static, a static library has no DLL. Instead of being in a separate DLL in case of dynamic linking, the SFML code will be integrated directly into your executable if you link the static libraries.

If you were searching the DLLs, what did you think the static version of SFML was, compared to the dynamic one? ;)

I thought there would be a sfml-graphics-s-d.dll file that could be included, I just cant get my project to build when using SFML_STATIC, frustrating to do so.
Title: Re: How to find the Static DLL's?
Post by: eXpl0it3r on April 09, 2014, 12:31:18 pm
Not sure if you understand what's going on here.

When you link dynamically on Windows you link against *.lib (VS) or *.a (MinGW) files, they do not contain any code and are called "import libraries". They simply tell the linker thing like: "I have a symbol XYZ and it's located in some.dll"
The linker is now happy and builds your executable. At runtime it will then go and look for that entry point in that dll and thus you'll need the dll files at runtime.

When you link statically on Windows you link against *.lib (VS) or *.a (MinGW) files. Now while they have the same file ending, it's not the same as the import libraries at all. SFML is helpful in that matter and provides the -s suffix. These static libraries actually contain all the code of the library. During the linking stage, the linker will look for the needed symbols in the static library and when used directly include it into the executable and since everything gets included there's no need for files such as *.dll.

I hope that helped - I hope to get the second part of the linking guide (http://dev.my-gate.net/2014/03/building-preprocessing-compiling-linking/) up on my blog soon enough. ;)
Title: Re: How to find the Static DLL's?
Post by: Laurent on April 09, 2014, 01:16:49 pm
Quote
I just cant get my project to build when using SFML_STATIC
It would be much more efficient to show us what compiler/linker errors you get, instead of trying to deduce a wrong solution by yourself and wasting everybody's time in the wrong direction ;)
Title: Re: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 01:26:03 pm
Quote
I just cant get my project to build when using SFML_STATIC
It would be much more efficient to show us what compiler/linker errors you get, instead of trying to deduce a wrong solution by yourself and wasting everybody's time in the wrong direction ;)

Decided against using static, I thought of just moving the dll's into a subfolder so its not being seen straight away. Is there a way I have Visual Studio 2013 compile with the dlls in a subfolder? e.g. "data/libs/sfml-graphics-2.dll"
Title: Re: How to find the Static DLL's?
Post by: MadMartin on April 09, 2014, 01:31:04 pm
Just why would you do that? It's possible by using LoadLibrary(), but this is a mere hack in my opinion. "Hiding away" is a very bad reason to do such things.

If you don't want any files other than your executable, you would have to choose the static libraries.
Title: Re: How to find the Static DLL's?
Post by: Laurent on April 09, 2014, 01:39:34 pm
So you really don't want to show us your error message(s)?
Title: Re: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 01:42:01 pm
So you really don't want to show us your error message(s)?

I never got any, thats the point.
Title: Re: How to find the Static DLL's?
Post by: eXpl0it3r on April 09, 2014, 01:52:04 pm
So if you don't get an error, how do you know something went wrong? ;D
Title: Re: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 02:24:37 pm
So if you don't get an error, how do you know something went wrong? ;D

I havent any clue  :-\ anyway, can you answer my question just before? Is it possible to load the dlls in subfolder when building/running?

e.g "data/libs/<sfml-dll here>"
Title: Re: How to find the Static DLL's?
Post by: Laurent on April 09, 2014, 02:37:37 pm
Seriously, there has to be something wrong, otherwise you wouldn't be here. So what is wrong when you link SFML statically? What is your problem?

Loading the DLLs from a sub-folder would requires a hack so you're unlikely to get many answers, people on this forum usually prefer to solve problems with clean solutions instead ;)
Title: Re: How to find the Static DLL's?
Post by: eXpl0it3r on April 09, 2014, 02:54:37 pm
So if you don't get an error, how do you know something went wrong? ;D
I havent any clue  :-\
So you have no idea, how you cam to the conclusion that something went wrong and you din't get any indication that something did go wrong, but you still know something went wrong? I guess it's time to get some philisophors in here: "I know that I know nothing". ;D

anyway, can you answer my question just before? Is it possible to load the dlls in subfolder when building/running?

e.g "data/libs/<sfml-dll here>"
There isn't.
Title: Re: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 04:21:59 pm
Ok, now it's spat out an error at me

Error   1       error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::White" (?White@Color@sf@@2V12@B)
 

Thats using SFML_STATIC
and linking sfml-graphics-s-d.lib when building etc.

It also spits out this

Error   11      error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1800' in game.obj
Title: Re: How to find the Static DLL's?
Post by: zsbzsb on April 09, 2014, 04:34:16 pm
Using VS 2012 libraries with VS 2013 will not work.
Title: Re: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 04:40:16 pm
Using VS 2012 libraries with VS 2013 will not work.

Well that stink's, my CMAKE I got earlier today doesnt even do VS 2013 :((
Title: Re: How to find the Static DLL's?
Post by: Jesper Juhl on April 09, 2014, 04:42:42 pm
Using VS 2012 libraries with VS 2013 will not work.

Well that stink's, my CMAKE I got earlier today doesnt even do VS 2013 :((
Remember that VS 2013 is == VS v. 12 ;)
Blame MS for confusing versioning...
Title: Re: How to find the Static DLL's?
Post by: JTeck on April 09, 2014, 04:44:24 pm
Using VS 2012 libraries with VS 2013 will not work.

Well that stink's, my CMAKE I got earlier today doesnt even do VS 2013 :((
Remember that VS 2013 is == VS v. 12 ;)
Blame MS for confusing versioning...
Sweet, I built a up to date one then earlier :) Woo, lets test.
Title: Re: How to find the Static DLL's?
Post by: Nexus on April 09, 2014, 07:07:49 pm
Remember that VS 2013 is == VS v. 12 ;)
Even that is wrong ;)

Visual Studio 2013 (the IDE)
is the same as
Visual C++ 12 (the compiler)

And since that is not confusing enough, also the term "Visual C++ 2013 Express" is used to refer to the Express Edition of the IDE. The reasoning is that it only includes support for C++ and not other languages, so it's no studio ;)
Title: Re: How to find the Static DLL's?
Post by: Jesper Juhl on April 09, 2014, 07:10:01 pm
Remember that VS 2013 is == VS v. 12 ;)
Even that is wrong ;)

Visual Studio 2013 (the IDE)
is the same as
Visual C++ 12 (the compiler)
Right you are. I should have double checked my memory.
I don't use Windows and related tools much. I guess it shows :(
Title: Re: How to find the Static DLL's?
Post by: Silvah on April 10, 2014, 03:19:44 pm
Remember that VS 2013 is == VS v. 12 ;)
Even that is wrong ;)

Visual Studio 2013 (the IDE)
is the same as
Visual C++ 12 (the compiler)
Not really, no. Jesper Juhl isn't wrong, Visual Studio 2013 is very much Visual Studio version 12, as shown in its "About" dialog, which says
Quote
Microsoft Visual Studio Express 2013 for Windows Desktop
Version 12.0.30110.00 Update 1
This is also the major version of the bundled runtime libraries.

The compiler major version, however, is 18, as can be seen when invoking cl.exe directly:
Quote
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x86

Getting this right can sometimes be important, for example when trying to detect VC++ 2013, because naively trying to do #if _MSC_VER == 1200 will fail, for the compiler version 12 is the one bundled with Visual Studio 6.0, released in 1998.
Title: Re: How to find the Static DLL's?
Post by: Nexus on April 10, 2014, 05:18:09 pm
You're right, maybe we should differentiate between version number and branding name.

On MSDN, Microsoft mostly refers to the IDE as "Visual Studio <year>", it's the name used for advertising. Because of that and the fact that people can relate better to a year than an abstract number, I think talking of Visual Studio 2013 instead of Visual Studio 12 leads to less confusion.
Title: Re: How to find the Static DLL's?
Post by: Daddi on April 12, 2014, 01:33:24 am
When you link statically on Windows you link against *.lib (VS) or *.a (MinGW) files. Now while they have the same file ending, it's not the same as the import libraries at all. SFML is helpful in that matter and provides the -s suffix. These static libraries actually contain all the code of the library. During the linking stage, the linker will look for the needed symbols in the static library and when used directly include it into the executable and since everything gets included there's no need for files such as *.dll.

I'd like to highjack the thread and ask a question: Why is the preprocessor flag SFML_STATIC necessary? Like you said, the "The linker is now happy and builds your executable" as long as he knows where to find the right code, may it be directly inside the lib or just linked into a .dll file. What does the preprocessor flag actually do?
Title: Re: How to find the Static DLL's?
Post by: FRex on April 12, 2014, 01:47:32 am
It conditionally defines macros that are later used in SFML headers called Export.hpp in all submodules folders and from there in all headers of each submodule.
If it's the SFML submodule itself being built they tell linker to export the symbols so they are visible from the outside.*
If it's another lib or program that uses SFML they'll tell linker to look around shared objects for implementation of the classes and functions defined in the SFML headers you included.
For static SFML all these macros actually do nothing since nothing special is needed for static linking.
See:
https://github.com/SFML/SFML/blob/master/include/SFML/Network/Export.hpp
https://github.com/SFML/SFML/blob/master/include/SFML/Config.hpp#L83

*I think these are actually what's inside .lib files in Windows but don't quote me on that...