I am making a simple Pong game and after finishing the game I tried to add a sound effect for the ball collision but the compiler would not compile the code and send some errors I made sure that openal32 is linked and the .dll is in the directory of the project. So I would write the whole game without a problem and as soon as I include
buf.loadFromFile("data\pong.wav");
Sound sound;
sound.setBuffer(buf);
The compiler won't even start the game and would give me those errors,I am using SFML 2.5.1 after compiling it for visual studio 2019 that I am using.
1>------ Build started: Project: Project1, Configuration: Debug x64 ------
1>Source.cpp
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(69,19): warning C4129: 'p': unrecognized character escape sequence
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(133,19): warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(137,20): warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(141,20): warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(151,19): warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(155,20): warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(159,20): warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(164,21): warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data
1>C:\Users\Ahmad.T\source\repos\Project1\Project1\Source.cpp(164,13): warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data
1>flac.lib(stream_decoder.obj) : error LNK2019: unresolved external symbol __iob_func referenced in function FLAC__stream_decoder_reset
1>flac.lib(stream_encoder.obj) : error LNK2001: unresolved external symbol __iob_func
1>flac.lib(win_utf8_io.obj) : error LNK2001: unresolved external symbol __iob_func
1>flac.lib(bitreader.obj) : error LNK2019: unresolved external symbol fprintf referenced in function FLAC__bitreader_dump
1>flac.lib(bitwriter.obj) : error LNK2001: unresolved external symbol fprintf
1>flac.lib(win_utf8_io.obj) : error LNK2019: unresolved external symbol vsnprintf_s referenced in function local_vsnprintf
1>MSVCRTD.lib(vsnprintf_s.obj) : error LNK2001: unresolved external symbol vsnprintf_s
1>MSVCRTD.lib(vsnprintf_s.obj) : error LNK2001: unresolved external symbol _vsnprintf_s
1>C:\Users\Ahmad.T\source\repos\Project1\x64\Debug\Project1.exe : fatal error LNK1120: 4 unresolved externals
1>Done building project "Project1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here are the libraries that are linked to the project:
flac.lib
opengl32.lib
openal32.lib
freetype.lib
winmm.lib
gdi32.lib
vorbisenc.lib
vorbisfile.lib
vorbis.lib
ogg.lib
ws2_32.lib
sfml-graphics-s-d.lib
sfml-window-s-d.lib
sfml-system-s-d.lib
sfml-audio-s-d.lib
sfml-network-s-d.lib
If you need a further look on the code I will include it in a comment if needed.
I think you used the wrong compiler. As SFML depends on a big number of underlying libraries (flac.lib is only one example..). These libraries are part of the download. However these libraries need to be used with the same compiler they were build.
That is why SFML is offering Downloads for different visual studio versions.
Between the versions Microsoft changed header definitions so now functions are defined different than in the delivered libraries(basically the header files changed between the different Visual Studio versions).
You may have success by
See this answer for a similar problem