NO

Author Topic: PlaySound POLINK error  (Read 2922 times)

Offline athene4

  • Member
  • *
  • Posts: 3
PlaySound POLINK error
« on: September 17, 2014, 08:22:29 PM »
I tried the following code snippet from Petzold:

case WM_CREATE:
   PlaySound(TEXT("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
   return 0 ;

And got the following POLINK: error: Unresolved external symbol '__imp_PlaySoundA'.
Version 8.00.19 Release Candidate #6 (Win64), included <windows.h>, <mmsystem.h>

neo313

  • Guest
Re: PlaySound POLINK error
« Reply #1 on: September 17, 2014, 08:37:11 PM »
This is not a bug.

Do not include <mmsystem.h>.  Including windows.h is all you need to do.

Add >>  Winmm.lib << to: Project options->Linker->Library and object files


Offline athene4

  • Member
  • *
  • Posts: 3
Re: PlaySound POLINK error
« Reply #2 on: September 17, 2014, 10:17:59 PM »
Thank you, it works well using Winmm.lib!
NB. Flag constants ('SND_FILENAME' etc.) are declared in <mmsystem.h> so I must include it.

neo313

  • Guest
Re: PlaySound POLINK error
« Reply #3 on: September 18, 2014, 04:02:32 AM »
No, windows.h automatically includes appropriate headers.

Offline athene4

  • Member
  • *
  • Posts: 3
Re: PlaySound POLINK error
« Reply #4 on: September 18, 2014, 10:28:42 AM »
It looks it was a side effect of #define WIN32_LEAN_AND_MEAN (from a program template).
I remove it along with <mmsystem.h>.
Thanks!