I'm trying to code a little program with a simple number guessing game.
I want to play an mp3 file behind it using a simple thread. I have read How to play or open *.mp3 or *.wav sound file in c++ program?, but I can't get it to work. It always spews out the error:
||=== Build: Debug in pinkpantherguessinggame (compiler: GNU GCC Compiler) ===|
C:\Users\Leon\Desktop\pCode\pinkpantherguessinggame\main.cpp|8|warning: ignoring #pragma comment [-Wunknown-pragmas]|
obj\Debug\main.o||In function `Z11pinkpantherv':|
C:\Users\Leon\Desktop\pCode\pinkpantherguessinggame\main.cpp|16|undefined reference to `_imp__mciSendStringA@16'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 1 warning(s) (0 minute(s), 1 second(s)) ===|
Here is my code:
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <windows.h>
#include <thread>
#include <Mmsystem.h>
#pragma comment(lib, "Winmm.lib")
using namespace std;
void start(int);
void pinkpanther()
{
mciSendString("open \"E:\\Users\\cdev\\Musik\\pinkpanther.mp\" type mpegvideo alias mp3", NULL, 0, NULL);
mciSendString("play mp3", NULL, 0, NULL);
}
I tried downloading winmm.lib
from somewhere, because it doesn't seem to find the library (just a guess).
Am I doing something wrong, or do I need to include some other header?