C++ wav playsound function

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <windows.h>
using namespace std;

int main ()
{
  PlaySound("F:\\Nightmare_Before_Christmas_-_This_is_Halloween.WAV", NULL, SND_ASYNC);
  cin.get();
  return 0;
}

when I play it I get
[Linker error] undefined reference to `PlaySoundA@12'
ld returned 1 exit status

how do I fix this? so it will play the wav file.
Last edited on
Please find specify correct linker properties, you have to point new dependency on some library.
Add #include <mmsystem.h>
and add winmm.dll or coredll.lib to linker libraries.

Cheers.
Daniele.
Header mmsystem.h
Library coredll.lib
Topic archived. No new replies allowed.