SFML community forums

Help => Audio => Topic started by: Xwilarg on November 21, 2019, 02:29:38 am

Title: Using sfml-audio on Windows
Post by: Xwilarg on November 21, 2019, 02:29:38 am
Hi,

I'm trying to use the SFML 2.5.1 on Windows and everything was working until I tried to use sfml audio.
When I'm trying to use sf::Music and I launch my program I have a segfault.

I already added openal32.dll next to my executable (I compiled the SFML on my computer to have it so it should be the right version).
I tried to launch my program on Visual Studio (2019) to have more information about it but I just got this:
Exception thrown at 0x00007FFD4023B40D (ntdll.dll) in RythmHero.exe: 0xC0000005: Access violation writing location 0x0000000000000008. occurred

Would someone please know how I could fix that?

Thanks in advance,
Title: Re: Using sfml-audio on Windows
Post by: eXpl0it3r on November 21, 2019, 07:57:46 am
Sounds like something isn't initialized. Can you provide a minimal example that reproduces the issue?
Title: Re: Using sfml-audio on Windows
Post by: Xwilarg on November 22, 2019, 05:37:40 pm
Hi,

Sorry for the late reply, I created this small project to show the issue: https://github.com/Xwilarg/sfml-audio-bug
Just launch build.sh to build, then launch test.exe and it should crash.
Title: Re: Using sfml-audio on Windows
Post by: eXpl0it3r on November 22, 2019, 06:08:50 pm
You're using a static (and thus globally) initialized sf::Music, which is not allowed by SFML, as the initialization as well as the destruction order of global objects are undefined an since SFML too uses some globals to hide certain magic.
Title: Re: Using sfml-audio on Windows
Post by: Xwilarg on November 24, 2019, 10:49:14 am
I'll change that then, thanks for your help