Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Can't play any sounds - Program crashes  (Read 2258 times)

0 Members and 1 Guest are viewing this topic.

Zoratu

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Can't play any sounds - Program crashes
« 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Can't play any sounds - Program crashes
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Zoratu

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Can't play any sounds - Program crashes
« Reply #2 on: September 21, 2017, 01:48:01 am »
Thanks changing the suffix to -d fixed it.

 

anything