Hello,
I am currently developping a project of a 3D video game in C++. I want to use the SFML Audio module to manage musics and sounds in my game. I use CMake to compile under both Linux and Windows.
Under Linux (compiles with c++ through generated Makefile), everything works perfectly fine, but when I try to launch under Windows (compiles with MSVC in a generated VS 16 (2019) solution), the SFML won't load the music anymore (more specifically, the loadFromFile function fails).
Here is the test code sample I use (directly in the main, which is just a big code sample for testing all my libraries so I just give here he SFML Audio related part):
sf::SoundBuffer soundBuffer; //Tried with a sf::SoundBuffer + sf::Sound
sf::Sound sound;
if (!soundBuffer.loadFromFile("assets/music/test_music.ogg")) // <-- fails here
return -2;
sound.setBuffer(soundBuffer);
sound.play();
/* Also tried with sf::Music, with this piece of code, fails exactly at the same function call
sf::Music music;
if (!music.openFromFile("assets/music/test_music.ogg")) // <-- fails here
return -3;
music.play();*/
This code runs fine under Linux, but for some reason not under Windows.
Here is what I already checked:
- The path is right (some other assets are accessed by other libs, so I know the assets directory is accessible, and I quintuple checked the rest of the path)
- The OGG Vorbis file is not corrupted (plays well in any media player both on Linux and Windows + recorded and encoded it myself in Audacity.
- The SFML dependencies are correctly loaded (.dll is in the build directory, .lib is linked in CMake, headers are included correctly.)
- I tried using the sfml-audio-d-2.dll instead of the smfl-audio-2.dll, just in case. Doesn't work either.
- The argument format (I checked there wasn't a problem of `WCHAR *` instead of `char *`)
I use the 64 bits library, because VS wouldn't accept the 32 bits one (saying I am compiling the project for 64 bits platforms -- which is intended). I switched without really thinking about it since the game is not meant to be played on 32 bits devices, could this cause problems?
Also, I am new to programming in C++ in Windows, so there might be something I did wrong in that aspect.
Thank you in advance for any help !