PlaySound not working

Hello.

I am having problems getting this file to be played:
C:\BLACKJACK\welcome.wav

(It's a .wav with a length of 1 sec.)

The file is located in the same folder as my .dev, .h and .cpp files

Here are my program:
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
#include <cstdlib>
#include <iostream>
#include "gfx.h"

using namespace std;

int main(int argc, char *argv[])
{
    welcome();
    system("PAUSE");
    return EXIT_SUCCESS;
}


gfx.cpp (This is where I put in the PlaySound
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <windows.h>
#include "gfx.h"
using namespace std;

void welcome() {
     PlaySound ("welcome.wav",NULL,SND_FILENAME|SND_ASYNC);
     cout << " /-------------\ \n";
     cout << "  W E L C O M E \n";
     cout << " \--------------/ \n";

}



gfx.h
1
2
3
4
5
6
#ifndef gfx_h
#define gfx_h

void welcome();

#endif 

(This are all the files I've created)

I will greatly appreciate any help!

/edit

The error log:
9:14 C:\BLACKJACK\gfx.cpp [Warning] '\040'
11:14 C:\BLACKJACK\gfx.cpp [Warning] unknown escape sequence '\-'
[Linker error] undefined reference to `PlaySoundA@12'
11:14 C:\BLACKJACK\gfx.cpp ld returned 1 exit status
C:\BLACKJACK\Makefile.win [Build Error] [blackjack.exe] Error 1



/edit2

Solved.

You enter:
-lwinmm

in compiler options -> "add these commands to the linker command line"
if you are using dev c++
Last edited on
Topic archived. No new replies allowed.