Using the W2K+SP4 platform.
When trying to build an .EXE, targetting a CONSOLE application that has
either one of the following two lines:
1. PlaySound("SystemExclamation",NULL,SND_ALIAS);
2. PlaySound("H:\\My_Music\\abc.mpg",NULL,SND_FILENAME | SND_ASYNC);
Compiler is happy but linker complains:
Test.obj : error LNK2019: unresolved external symbol __imp__PlaySoundA@12
referenced in function _main
Release/Test.exe : fatal error LNK1120: 1 unresolved externals
I do have the following inclusions:
#include <iostream>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <winver.h>
using namespace std;
What am I missing ? Any additional header or .DLL/.OBJ (static) linking
required?
Or is it possible that I can not target a Console application using the
PlaySound() function?
What are the alternative functions if PlaySound() is inappropriate?
Many thanks,
David
Alin Constantin [MSFT] - 22 Dec 2003 19:41 GMT
Hi David,
As per
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_w
in32_playsound.asp
the PlaySound function is implemented in Winmm.lib
Header: Declared in Mmsystem.h; include Windows.h.
Library: Use Winmm.lib.
So, you need to link to that library in order to use the function.
If you're using VisualStudio 2002/2003, use the Project's property pages and
add 'winmm.lib' in the Linker/Input/AdditionalDependencies list.

Signature
Alin Constantin
[This posting is provided "AS IS" with no warranties, and confers no
rights.]
> Using the W2K+SP4 platform.
>
[quoted text clipped - 29 lines]
>
> David