Archived

This topic is now archived and is closed to further replies.

Idhrendur

Linker Error/Where did PlaySound() go?

Recommended Posts

I was doing some research on MSDN on the windows API for sound, and I found the function PlaySound(). It seemed exactly what I needed, so I put it in my code. I confirmed the only include I needed was windos.h, then went to compile my code. So what should happen, but I get the linker error game.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12 Why can''t the linker find PlaySound. It should be there when I include windows.h. When I typed it in, VC++ (6.0) even showed me the parameters I needed, like it does whenever I''ve got things right. Just in case, here''s the function that uses PlaySound():
void play_sound(sound choice) {
	switch (choice) {
		case blocked:
			PlaySound("blocked.wav", NULL, SND_ASYNC | SND_FILENAME);
			break;
		case landed:
			break;
		case cleared:
			break;
	}
}

Share this post


Link to post
Share on other sites
OK, you need two things.
First #include <mmsystem.h>
Second, link winmm.lib in your project.

Google is your friend.

[edit] Oh, and just because you can get all the info on the function in the IDE does not mean you have the proper libs/headers included. Sucks don't it?

You might also want to look at msdn

[edited by - jflanglois on May 19, 2004 2:22:50 AM]

Share this post


Link to post
Share on other sites
Thank you. It worked just fine.

I guess I didn''t understand the line in MSDN that said:
Library: Use Winmm.lib.

Ah well, this is how you learn.

Share this post


Link to post
Share on other sites