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

Author Topic: SFML Audio Dependencies  (Read 10641 times)

0 Members and 3 Guests are viewing this topic.

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
SFML Audio Dependencies
« on: February 23, 2017, 06:27:32 am »
After much headache, I've finally got SFML mostly working both when linking dynamically and statically, but one thing still eludes me:

Audio. I have the following setup:

- openal32.dll in my project folder next to my .exe

- the following libraries statically linked in the following order:
sfml-graphics-s-d
freetype
jpeg
sfml-window-s-d
opengl32
gdi32
sfml-audio-s-d
openal32 [Edit] woops! Didn't have this linked after all... Read further to understand my confusion on this point if you encounter this problem :)
flac
vorbisenc
vorbisfile
vorbis
ogg
sfml-network-s-d
sfml-system-s-d
winmm

and the following, relevant code:
#include <SFML/Graphics.hpp>
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <math.h>
#include <SFML/System/Vector2.hpp>
#include <SFML/Audio.hpp>

[...]

    //Audio
    sf::SoundBuffer buffer;
    if (!buffer.loadFromFile("jump.wav"))
        return -1;
    sf::Sound sound;
    sound.setBuffer(buffer);
    sound.play();

[...]
 

My error message:
||=== Build: Debug in ProtoGame (compiler: GNU GCC Compiler) ===|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundBuffer.cpp.obj)||In function `ZN2sf11SoundBufferC2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundBuffer.cpp|46|undefined reference to `_imp__alGenBuffers'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundBuffer.cpp.obj)||In function `ZN2sf11SoundBufferC2ERKS0_':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundBuffer.cpp|58|undefined reference to `_imp__alGenBuffers'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundBuffer.cpp.obj)||In function `ZN2sf11SoundBufferD2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundBuffer.cpp|80|undefined reference to `_imp__alDeleteBuffers'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundBuffer.cpp.obj)||In function `ZNK2sf11SoundBuffer13getSampleRateEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundBuffer.cpp|180|undefined reference to `_imp__alGetBufferi'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundBuffer.cpp.obj)||In function `ZNK2sf11SoundBuffer15getChannelCountEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundBuffer.cpp|190|undefined reference to `_imp__alGetBufferi'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundBuffer.cpp.obj)||In function `ZN2sf11SoundBuffer6updateEjj':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundBuffer.cpp|265|undefined reference to `_imp__alBufferData'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZN2sf5Sound4playEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|73|undefined reference to `_imp__alSourcePlay'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZN2sf5Sound5pauseEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|80|undefined reference to `_imp__alSourcePause'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZN2sf5Sound4stopEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|87|undefined reference to `_imp__alSourceStop'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZN2sf5Sound9setBufferERKNS_11SoundBufferE':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|104|undefined reference to `_imp__alSourcei'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZN2sf5Sound7setLoopEb':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|111|undefined reference to `_imp__alSourcei'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZN2sf5Sound16setPlayingOffsetENS_4TimeE':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|118|undefined reference to `_imp__alSourcef'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZNK2sf5Sound7getLoopEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|133|undefined reference to `_imp__alGetSourcei'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZNK2sf5Sound16getPlayingOffsetEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|143|undefined reference to `_imp__alGetSourcef'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(Sound.cpp.obj)||In function `ZN2sf5Sound11resetBufferEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\Sound.cpp|192|undefined reference to `_imp__alSourcei'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(ALCheck.cpp.obj)||In function `ZN2sf4priv12alCheckErrorEPKcjS2_':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\ALCheck.cpp|41|undefined reference to `_imp__alGetError'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(AudioDevice.cpp.obj)||In function `ZN2sf4priv11AudioDeviceC2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|54|undefined reference to `_imp__alcOpenDevice'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|59|undefined reference to `_imp__alcCreateContext'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|64|undefined reference to `_imp__alcMakeContextCurrent'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|73|undefined reference to `_imp__alListenerf'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|74|undefined reference to `_imp__alListener3f'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|75|undefined reference to `_imp__alListenerfv'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(AudioDevice.cpp.obj)||In function `ZN2sf4priv11AudioDeviceD2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|93|undefined reference to `_imp__alcMakeContextCurrent'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|95|undefined reference to `_imp__alcDestroyContext'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|99|undefined reference to `_imp__alcCloseDevice'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(AudioDevice.cpp.obj)||In function `ZN2sf4priv11AudioDevice20isExtensionSupportedERKSs':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|115|undefined reference to `_imp__alcIsExtensionPresent'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|117|undefined reference to `_imp__alIsExtensionPresent'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(AudioDevice.cpp.obj)||In function `ZN2sf4priv11AudioDevice25getFormatFromChannelCountEj':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|138|undefined reference to `_imp__alGetEnumValue'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|139|undefined reference to `_imp__alGetEnumValue'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|140|undefined reference to `_imp__alGetEnumValue'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|141|undefined reference to `_imp__alGetEnumValue'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(AudioDevice.cpp.obj)||In function `ZN2sf4priv11AudioDevice15setGlobalVolumeEf':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|157|undefined reference to `_imp__alListenerf'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(AudioDevice.cpp.obj)||In function `ZN2sf4priv11AudioDevice11setPositionERKNS_7Vector3IfEE':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|174|undefined reference to `_imp__alListener3f'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(AudioDevice.cpp.obj)||In function `ZN2sf4priv11AudioDevice12setDirectionERKNS_7Vector3IfEE':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|193|undefined reference to `_imp__alListenerfv'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(AudioDevice.cpp.obj)||In function `ZN2sf4priv11AudioDevice11setUpVectorERKNS_7Vector3IfEE':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\AudioDevice.cpp|213|undefined reference to `_imp__alListenerfv'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSourceC2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|37|undefined reference to `_imp__alGenSources'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|38|undefined reference to `_imp__alSourcei'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSourceC2ERKS0_':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|45|undefined reference to `_imp__alGenSources'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|46|undefined reference to `_imp__alSourcei'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSourceD2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|60|undefined reference to `_imp__alSourcei'|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|61|undefined reference to `_imp__alDeleteSources'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSource8setPitchEf':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|68|undefined reference to `_imp__alSourcef'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSource9setVolumeEf':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|75|undefined reference to `_imp__alSourcef'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSource11setPositionEfff':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|82|undefined reference to `_imp__alSource3f'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSource21setRelativeToListenerEb':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|96|undefined reference to `_imp__alSourcei'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSource14setMinDistanceEf':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|103|undefined reference to `_imp__alSourcef'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZN2sf11SoundSource14setAttenuationEf':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|110|undefined reference to `_imp__alSourcef'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZNK2sf11SoundSource8getPitchEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|118|undefined reference to `_imp__alGetSourcef'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZNK2sf11SoundSource9getVolumeEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|128|undefined reference to `_imp__alGetSourcef'|
C:\SFML-2.4.1\lib\libsfml-audio-s-d.a(SoundSource.cpp.obj)||In function `ZNK2sf11SoundSource11getPositionEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Audio\SoundSource.cpp|138|undefined reference to `_imp__alGetSource3f'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
 

What am I missing?

I'm finding that the dependencies are not fully listed in the tutorials *or* the documentation - even the basic "SFML Works!" program requires libraries not mentioned anywhere in the tutorial. The list of dependencies I am using is just a list that I found in an online search  for "full list of sfml dependencies in order" - but even it is incomplete / wrong, as I discovered a few quirks, namely:
-openal32 cannot be linked statically
-ws2-32, whatever it is, does not exist on my machine or installation of sfml to my knowledge. Not sure if this is relevant or not to the problem.
-audio still doesn't work for some reason which I hope to solve
« Last Edit: February 23, 2017, 09:07:55 am by Argus »

JayhawkZombie

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: SFML Audio Dependencies
« Reply #1 on: February 23, 2017, 06:35:11 am »
Are you using release libs and building in debug?

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: SFML Audio Dependencies
« Reply #2 on: February 23, 2017, 06:43:41 am »
I'm actually not using release libs, which is why I'm confused about those error messages. I'm building in debug and linking to -s-d libraries.

I'm using code blocks, for reference.

I didn't actually link to the audio libraries in my release setup. Could that still be causing errors even though I'm building the project in Debug?

Edit: I've double, triple, quadruple checked, and linked the -s-d libraries in debug and the -s libraries in static and it still doesn't work...
I also added a file, ws2_32, which I found in my Windows/system32 folder, and it makes no difference.
« Last Edit: February 23, 2017, 06:57:15 am by Argus »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
SFML Audio Dependencies
« Reply #3 on: February 23, 2017, 08:07:15 am »
So where did you copy/download from the static OpenAL lib that you're trying linking?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML Audio Dependencies
« Reply #4 on: February 23, 2017, 08:16:35 am »
Quote
I'm finding that the dependencies are not fully listed in the tutorials *or* the documentation - even the basic "SFML Works!" program requires libraries not mentioned anywhere in the tutorial. The list of dependencies I am using is just a list that I found in an online search  for "full list of sfml dependencies in order"
Really? It is exactly the list given in the tutorials. And no, it is not wrong nor incomplete, it does work.
Let's first solve your problem, and draw conclusions about the documentation later ;)

Quote
-openal32 cannot be linked statically
The official documentation never says it can. And that's why the SFML SDK contains the corresponding DLL.

Quote
-ws2-32, whatever it is, does not exist on my machine or installation of sfml to my knowledge.
I can't see any error in your linker log about ws2_32, which means that it is correctly found and linked. So what's wrong with it?

Quote
-audio still doesn't work for some reason which I hope to solve
Yes, let's focus on that please. Going into "SFML doesn't work" or "documentation is wrong" discussions won't help to solve your specific problem ;)
Laurent Gomila - SFML developer

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: SFML Audio Dependencies
« Reply #5 on: February 23, 2017, 08:31:56 am »
So where did you copy/download from the static OpenAL lib that you're trying linking?

SFML-2.4.1/bin
I'm just throwing it next to my exe in my Debug folder. I assume that is sufficient for dynamic linking, correct?
I'm not entirely sure how to mix both static and dynamic linking in Code::Blocks.
It seems to work and doesn't complain when, say, initialiazing variables. But when I try loading/playing sounds, I get compile errors.

Am I doing something wrong here?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
SFML Audio Dependencies
« Reply #6 on: February 23, 2017, 08:42:03 am »
Since you list openal32 and the linker doesn't complain about it not being found, it means you must have a libopenal32.a located somewhere. But because the linker can't find the dynamic/import (_imp__) symbols in that provided libopenal32.a, it means that you must have obtained a static version of libopenal32.a from somewhere other than SFML.
So what steps did you take in trying to get OpenAL to work. Tell us even the ones that in your opinion failed.

Or the other possibility is that in the end you forgot to actually link against openal32 or in the wrong order. For that you should provide the full build command.
« Last Edit: February 23, 2017, 08:43:44 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: SFML Audio Dependencies
« Reply #7 on: February 23, 2017, 08:42:51 am »
Quote
I'm finding that the dependencies are not fully listed in the tutorials *or* the documentation - even the basic "SFML Works!" program requires libraries not mentioned anywhere in the tutorial. The list of dependencies I am using is just a list that I found in an online search  for "full list of sfml dependencies in order"
Really? It is exactly the list given in the tutorials. And no, it is not wrong nor incomplete, it does work.
Let's first solve your problem, and draw conclusions about the documentation later ;)

Quote
-openal32 cannot be linked statically
The official documentation never says it can. And that's why the SFML SDK contains the corresponding DLL.

Quote
-ws2-32, whatever it is, does not exist on my machine or installation of sfml to my knowledge.
I can't see any error in your linker log about ws2_32, which means that it is correctly found and linked. So what's wrong with it?

Quote
-audio still doesn't work for some reason which I hope to solve
Yes, let's focus on that please. Going into "SFML doesn't work" or "documentation is wrong" discussions won't help to solve your specific problem ;)

Sorry - I'm just incredibly frustrated, and following the tutorials to the letter and still getting errors (and googling them only to get other people doing the same thing, often without resolutions to the problems) is discouraging.

I can say that I did need to include jpeg to make the example work, and a lot of other things were not straight forward/seem not to be mentioned. It could be written more clearly, and I have some suggestions regarding how to do that which I think would help people like myself who might otherwise spend days googling and asking questions here just to get things working! Perhaps here is not the place to discuss this, though.

So, is there anything you can tell that I have apparently missed in regards to Audio?
« Last Edit: February 23, 2017, 08:50:56 am by Argus »

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: SFML Audio Dependencies
« Reply #8 on: February 23, 2017, 08:48:20 am »
Since you list openal32 and the linker doesn't complain about it not being found, it means you must have a libopenal32.a located somewhere. But because the linker can't find the dynamic/import (_imp__) symbols in that provided libopenal32.a, it means that you must have obtained a static version of libopenal32.a from somewhere other than SFML.
So what steps did you take in trying to get OpenAL to work. Tell us even the ones that in your opinion failed.

I did the following:
- tried to link to it along with everything else. I did this by simply adding it to the list of linked (debug) libraries as "openal32"

- got errors, googled, and found that it can't be statically linked.

- did a search on my computer for openal32.dll, found it in my SMFL-2.4.1/bin folder, copied it into my project folder.

- It appeared to work. I could declare variables such as sf::SoundBuffer without a problem.

- I then tried loading and playing a sound with the following lines and got the above compiler errors:
    sf::SoundBuffer buffer;
    if (!buffer.loadFromFile("jump.wav"))
        return -1;
    sf::Sound sound;
    sound.setBuffer(buffer);
    sound.play();
« Last Edit: February 23, 2017, 08:52:41 am by Argus »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
SFML Audio Dependencies
« Reply #9 on: February 23, 2017, 08:52:36 am »
Recheck that you're actually linking openal32 for the given project settings and make sure it's listed after sfml-audio.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: SFML Audio Dependencies
« Reply #10 on: February 23, 2017, 09:01:13 am »
Oh, geez. Apparently I don't understand the nature of dynamic linking and the SFML_STATIC flag.

I was under the impression that:
- simply having the dll in the appropriate folder meant that it was implicitly linked dynamically
- including it in the linked list would make it static

So I had removed it from the linked list when I copied it into my project folder.

I readded it to the list and it works now. Thanks a lot!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML Audio Dependencies
« Reply #11 on: February 23, 2017, 10:21:22 am »
Quote
I can say that I did need to include jpeg to make the example work
The "getting started" tutorial mentions it, in the list of libraries to link in case of static linking.

Quote
and a lot of other things were not straight forward/seem not to be mentioned. It could be written more clearly, and I have some suggestions regarding how to do that
Suggestions about how to improve the documentation are always welcome :)

Quote
I was under the impression that:
- simply having the dll in the appropriate folder meant that it was implicitly linked dynamically
- including it in the linked list would make it static
You always have to link a library that you use, and it's the library itself which is built either as a static one or a dynamic one (that's why you have both regular and -s libraries in SFML).
And there's no such thing as "implicit linking".
Laurent Gomila - SFML developer

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: SFML Audio Dependencies
« Reply #12 on: February 23, 2017, 11:48:21 am »
Quote
I can say that I did need to include jpeg to make the example work
The "getting started" tutorial mentions it, in the list of libraries to link in case of static linking.

Quote
and a lot of other things were not straight forward/seem not to be mentioned. It could be written more clearly, and I have some suggestions regarding how to do that
Suggestions about how to improve the documentation are always welcome :)

Quote
I was under the impression that:
- simply having the dll in the appropriate folder meant that it was implicitly linked dynamically
- including it in the linked list would make it static
You always have to link a library that you use, and it's the library itself which is built either as a static one or a dynamic one (that's why you have both regular and -s libraries in SFML).
And there's no such thing as "implicit linking".

Thanks. As you can tell, I'm kind of new to C++ and still wrapping my head around this linking business! I think what mystified me is that the dynamic build I made worked without linking the non-sfml "libraries," (I had included the main 3 SFML ones from the tutorial, but I figured that was redundant since my static build required many more dependencies), so I figured that dynamic linking must just search everything on your path (how else would it find standard C/C++ libraries?) and assumed that to be the same for user libraries as well. It seems oddly inconsistent that it doesn't work that way!

[Edit] Except that, I just realized, I don't have SFML on my path :P
Actually, maybe this is consistent and I just wasn't thinking. Would it dynamically link "automatically" if it were on my path?
« Last Edit: February 23, 2017, 11:53:54 am by Argus »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: SFML Audio Dependencies
« Reply #13 on: February 23, 2017, 11:53:28 am »
I think what mistified me is that the dynamic build I made worked without linking the non-sfml "libraries," (I had included the main 3 SFML ones from the tutorial, but I figured that was redundant since my static build required many more dependencies), so I figured that dynamic linking must just search everything on your path (how else would it find standard C/C++ libraries?) and assumed that to be the same for user libraries as well. It seems oddly inconsistent that it doesn't work that way!
The dynamic SFML libraries were already linked against the other libraries, thus they are "included" in the SFML libraries themselves. When you decide to go with static linking, you're basically saying to yourself, that you want to do everything and as such, it's also your responsibility to link the other libraries.
In earlier versions of SFML, this wasn't the case, but back then there was an ugly hack, which lead to issues.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Argus

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: SFML Audio Dependencies
« Reply #14 on: February 23, 2017, 12:00:15 pm »
I think what mistified me is that the dynamic build I made worked without linking the non-sfml "libraries," (I had included the main 3 SFML ones from the tutorial, but I figured that was redundant since my static build required many more dependencies), so I figured that dynamic linking must just search everything on your path (how else would it find standard C/C++ libraries?) and assumed that to be the same for user libraries as well. It seems oddly inconsistent that it doesn't work that way!
The dynamic SFML libraries were already linked against the other libraries, thus they are "included" in the SFML libraries themselves. When you decide to go with static linking, you're basically saying to yourself, that you want to do everything and as such, it's also your responsibility to link the other libraries.
In earlier versions of SFML, this wasn't the case, but back then there was an ugly hack, which lead to issues.

Ah. That kind of makes sense, I suppose.

The more I think about this, the more I realize that there is a lot of magic going on that I don't understand, though. How, for example, does the compiler know where to look for dlls like "opengl32" without my giving it any kind of path to that file, or having that file on my path (to my knowledge. Maybe I do? / same with all of the other dependencies like gdi32, winmm, jpeg, etc. etc.?)

At first I was actually looking for these files on my system and trying to find/link to the full url and extension, before I realized that SFML/the compiler somehow just "know" these files and where to look for them ???
« Last Edit: February 23, 2017, 12:02:04 pm by Argus »

 

anything