OpenGL and Music

Hey all,

Am trying to get a .wav file to play when my animation start, however get 2 errors. The line that i am using to play the music are:

if (z == 0.0f && y == 0.0f && music!=true){
music = true;
PlaySound("/Data/Track 12.wav", NULL, SND_ASYNC);
}

The errors are:
lesson10.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12

Debug/lesson10.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Can anyone tell me of an alternative way to play the track.

Thanks

The function def for playsound is obviously not found by the compiler. Is it in a library somewhere??

This belongs on an OpenGL forum because…???

<pulls up MSDN’s information on PlaySound>

Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Mmsystem.h; include Windows.h.
Library: Use Winmm.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.

My guess is you didn’t link in Winmm.lib… Now was that so hard?

Originally posted by Deiussum:
[b]This belongs on an OpenGL forum because…???

<pulls up MSDN’s information on PlaySound>
My guess is you didn’t link in Winmm.lib… Now was that so hard?[/b]

Am a beginer with OpenGL, so my question is: how do you link in Winmm.lib??

Hi !

Depends on what you are compiling with…

MinGW/gcc: there is a -l option to tell what libraries to use.

VC: goto project options, linker flags, “Input” tab, there you can add libraries.

Mikael

the easiest way to link winmm.lib is to do a
#pragma comment(lib, “winmm.lib”) in your code somewhere.

Originally posted by mike55:
[b] Am a beginer with OpenGL, so my question is: how do you link in Winmm.lib??

[/b]

Obviously a beginner to C/C++ too. Linking libraries, and Winmm.lib have nothing to do with OpenGL. Linking libraries is compiler specific (The above posts already tell you how to do this with VC++), and Winmm.lib is a Microsoft library, which in no way relates to OpenGL.

Hey all,

Thanks a million, appreciate it. Music is working perfectly, granted there is a delay in the final product opening up, but it is an acceptable delay.

Again many thanks.