How to play a music file.

I can't seem to get this to work here.

I'm trying to play a midi music file.

Any ideas?

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <windows.h>
#include <mmsystem.h>  // mciSendString()
#include <conio.h>

int main()
{
        mciSendString("play C:\\Users\\Home_Computer\\Desktop\\music.mid",NULL,0,NULL); //start music file at directory listed here
        return 0;
}
closed account (NUj6URfi)
What errors do you get?
Just one error message

C:\Users\Home_Computer\Desktop\playmusic\main.cpp|8|undefined reference to `mciSendStringA@16'|
I looked at this a little more.

It seems to use the mciSendString I need to link to a library called winmm.lib

Now to see if i can figure out how to link a library in codeblocks :\

That's assuming I can even find the file for download. I'll look tomorrow but if anybody knows a download link I'd be grateful.
Last edited on
Topic archived. No new replies allowed.