SFML community forums

Help => Audio => Topic started by: Zoratu on September 21, 2017, 12:03:34 am

Title: Can't play any sounds - Program crashes
Post by: Zoratu on September 21, 2017, 12:03:34 am
Hi I really need help with getting audio to work in my program. I've been working on it for awhile and I just can't figure it out.

When I try to run my program it just crashes and the exception it gives me is:
Exception thrown at 0x5719D687 (vcruntime140.dll) in Spacehip Game.exe: 0xC0000005: Access violation reading location 0x00542000. occurred

My code is (I had more but I started a new project to see if that would fix it):
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

int main() {
   sf::Music music;
   if (!music.openFromFile("music.wav"))
      return -1; // error
   music.play();

   //sf::RenderWindow window(sf::VideoMode(800, 600), "This is dumb");
}

I'm sure that my .wav file is in the right place and it plays when I use windows media player. A strange thing about the error is it gives me a bunch of random symbols, I attached a screenshot so people can see it.

Thanks for taking the time to help me. If I need to provide any more info I will.
Title: Re: Can't play any sounds - Program crashes
Post by: eXpl0it3r on September 21, 2017, 01:08:08 am
You're mixing debug and release modes. You can only link debug libraries (-d suffix) in debug mode and release libraries (no -d suffix) in release mode.
Title: Re: Can't play any sounds - Program crashes
Post by: Zoratu on September 21, 2017, 01:48:01 am
Thanks changing the suffix to -d fixed it.