PDA

View Full Version : OpenGL and Music



mike55
11-17-2003, 08:53 AM
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

mdog1234
11-17-2003, 09:17 AM
The function def for playsound is obviously not found by the compiler. Is it in a library somewhere??

Deiussum
11-17-2003, 09:34 AM
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?

mike55
11-18-2003, 04:10 AM
Originally posted by Deiussum:
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?

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

mikael_aronsson
11-18-2003, 04:22 AM
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

mdog1234
11-18-2003, 04:23 AM
the easiest way to link winmm.lib is to do a
#pragma comment(lib, "winmm.lib") in your code somewhere.

Deiussum
11-18-2003, 06:14 AM
Originally posted by mike55:
Am a beginer with OpenGL, so my question is: how do you link in Winmm.lib??



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.

mike55
11-18-2003, 06:47 AM
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.