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