Everytime i try to use the API function "PlaySound" I get this compiler error..

Compiler error "Undefined reference to PlaySoundA@12", i thought this function was included in the header <windows.h>? or is it included in another library?

anyway here is my code..

1
2
3
4
5
6
7
8
9
10
11
12

LRESULT CALLBACK WindowProcedure (HWND handle, UINT message, WPARAM wParam, LPARAM lParam)    
{
    switch (message)                  /* handle the messages */
    {

        case WM_CREATE:
            PlaySound ("Misfortune.gb", NULL, SND_FILENAME);        /*Misfortune.gb is the name of the wav file */
            return 0;

    }
}
Last edited on
Nevermind, i figured it out. It turns out that i needed to include the library winmm into the linker settings of the compiler
... i figured it out...

Did you (eventually) check the MSDN entry for PlaySound ?? Whenever you start working with a new API calls, it's a good idea to check the documentation on it!

PlaySound function
https://msdn.microsoft.com/en-us/library/windows/desktop/dd743680%28v=vs.85%29.aspx

From this entry:

Requirements

Minimum supported client
	Windows 2000 Professional [desktop apps only]

Minimum supported server
	Windows 2000 Server [desktop apps only]

Header
	Mmsystem.h (include Windows.h)

Library
	Winmm.lib

DLL
	Winmm.dll

Unicode and ANSI names
	PlaySoundW (Unicode) and PlaySoundA (ANSI)
Topic archived. No new replies allowed.