The following steps tell how to create a project file to play a wav sound file
1- create a project file.

2-Choose Console Application in Basic tab.

3-After Create the Project File go to Project Option

4-Choose Parameter tab

5-Click the Add Library or Object

6-Browse the location of Dev-c++ lib and choose the libwinmm

7-click ok and exit the Project Option

8-type the below source code

#include <windows.h>
#include <mmsystem.h>
#include <conio.h>

using namespace std;

int main(int argc, char *argv[])
{
PlaySound("chimes.wav",NULL,SND_FILENAME|SND_ASYNC);//PLAY WAV SOUND ONCE

//PlaySound("chimes.wav",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);
//ANOTHER OPTION PLAY REPEATED WAV SOUND

getch(); 
return 0;
}

Now my problem statement is to just create a C or Cpp file to play the wav file by not creating a project.I have tried a lot but couldn't do so.The reason probably might be with adding libwinmm to the program.The above procedure tells about adding it to project but how shall I do the same if I want to play it just in a file.(I mean what about libwinmm)

Recommended Answers

All 3 Replies

If you're trying to compile this at the command line, then it would be something like gcc prog.c -lwinmm where the winmm specifies the name of the library to link with, in this case libwinmm.a

In now solved the prob..basically it was a linker error

wow... that really helped me!!
:)
thanks!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.