Public Group

#### Archived

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

# Linker Error/Where did PlaySound() go?

This topic is 5150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
OK, you need two things.
First #include <mmsystem.h>

 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 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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631435
• Total Posts
3000056
×