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

Author Topic: Static linking and website tutorial  (Read 1402 times)

0 Members and 1 Guest are viewing this topic.

AlexRTX

  • Newbie
  • *
  • Posts: 2
    • View Profile
Static linking and website tutorial
« on: March 07, 2014, 10:03:19 am »
Hey there,

I just compiled SFML for Visual Studio 2013 and as I am just at the start of learning programming I have a few questions and I would really appreciate if you could help me.

1. I specified the additional dependencies in the Linker ( sfml-system-s.lib sfml-window-s.lib sfml-audio-s.lib sfml graphics-s.lib sfml-main.lib ) and the preprocessor definition ( SFML_STATIC ) but I couldn't compile a simple example of SFML code from the website. It seems that there were some kind of external dependency errors. I eventually got over them with  :

#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib")  
#endif // SFML_STATIC

As I understand the libraries that I included depend on other libraries ( the ones above ) and I have to link them too. The above code includes them if it finds the SFML_STATIC def. Now, from what I understand this is not the proper way to do it. I want to link them as I linked the other libraries but I can't seem to find all of them. For example, in the lib folder I have the glew, freetype, jpeg but not the opengl32, winm or gdi32. Where can I find them ?

2. On the tutorial section of the website it says :
Quote
If you are using the sfml-audio module (either statically or dynamically), you must also copy the DLLs of the external libraries needed by it, which are libsndfile-1.dll and OpenAL32.dll.

Although I linked the audo lib to the project and also included <SFML/Audio.hpp> the application works without having the 2 DLL in the same folder. Why is that ? Also, can those 2 libs be linked like the static libs that I linked previously ? Do they really need to be there as dynamic libraries ? If so, why is that and why does my program run without the DLLs or without even linking them ?

Appreciate your help !
« Last Edit: March 07, 2014, 10:05:11 am by AlexRTX »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Static linking and website tutorial
« Reply #1 on: March 07, 2014, 10:10:58 am »
1. opengl32, winm and gdi32 are standard libs, they are shipped with your compiler and are directly available.

2. It means that you have a version of these 2 DLLs somewhere, in a directory which is contained in the PATH environment variable.
Laurent Gomila - SFML developer

AlexRTX

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Static linking and website tutorial
« Reply #2 on: March 07, 2014, 10:23:24 am »
Thank you ! I managed to compile it now without the work-around by linking all the libs :

sfml-system-s.lib
sfml-window-s.lib
sfml-audio-s.lib
sfml-graphics-s.lib
sfml-main.lib
freetype.lib
glew.lib
jpeg.lib
opengl32.lib
winmm.lib
gdi32.lib

It seems kinda odd that I link opengl32 the same way I link the other libs although it's not located in the Additional Dependencies folder that i specified.

Yes, my mistake, sorry. I forgot that I copied those 2 DLLs in the bin folder of VC. Thank you again for helping me ! Can I somehow include them in the exe ?

« Last Edit: March 07, 2014, 10:27:39 am by AlexRTX »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Static linking and website tutorial
« Reply #3 on: March 07, 2014, 11:38:08 am »
Quote
Can I somehow include them in the exe ?
Their license doesn't allow it.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Static linking and website tutorial
« Reply #4 on: March 07, 2014, 12:01:49 pm »
Their license doesn't allow it.
Unless you put your code under GPL/LGPL (but then you'll have to compile them yourself and change SFML's CMake script etc.). ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/