Jin
Jin

Reputation: 1

My GCC compiler didn't identify the PlaySound function

I'm kinda confused when having the PlaySound function in my code. I did a double check the syntax and pretty sure I used the necessary library.

I'm using GCC version 5.1.0 and I had my WAV file in the same directory. Also, here is my code and the error in the console:

#include <iostream>
#include <windows.h>
#include <cstdlib>
#include <mmsystem.h>
#pragma comment(lib,"winmm.lib")

int main(){
 for(;;){
  PlaySound("C:\\Users\\ACER\\Documents\\Tick.WAV", NULL, SND_ASYNC | SND_FILENAME);
  Sleep(1000);
 }
return 0;
}

Error in console:
C:\Users\ACER\AppData\Local\Temp\ccokPOhD.o:test1.cpp:(.text+0x2e): unidentified reference to '_imp__PlaySoundA@12'
collect2.exe: error: ld returned 1 exit status

If I'm doing anything wrong or missing something, please let me know. Thank you.

Upvotes: 0

Views: 25

Answers (0)

Related Questions