0

I would like to make a question as far as an application regarding music manipulation is concerned: I compile a program with the function PlaySound() but the following message shows up: [Linker error] undefined reference to `PlaySoundA@12'. I use Dev c++ to do that, because I have a problem with the visual studio and I can not sign in to my Microsoft account and does not let me to use it. Well I dont't know what is going wrong and does not let me play the sound. I include the windows.h and mmsystem.h headers and all are properly written. Can anyone help me with that?

#include <windows.h>
#include <mmsystem.h>

int main(){
    PlaySound("test.wav", NULL, SND_FILENAME);
    return 0;
}
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – πάντα ῥεῖ May 05 '16 at 17:22
  • Probably also helpful [Problems importing libraries to my c++ project, how to fix this?](http://stackoverflow.com/questions/24715864/problems-importing-libraries-to-my-c-project-how-to-fix-this) – πάντα ῥεῖ May 05 '16 at 17:23

2 Answers2

1

You need to link the compiler to the winmm.lib library for this to properly link.

William
  • 41
  • 6
1

Just add the following line before the main function.

#pragma comment(lib, "Winmm.lib")

Christopher Nolan
  • 930
  • 1
  • 11
  • 15