Fatal error LNK1120 - mciSendString ?

Aug 13, 2010 at 10:44am
Hi,
I'm trying to get the mciSendString working to play a mp3 file.
But when I try to compile I get the following error:
fatal error LNK1120: 1 unresolved externals

I can't seem to find the problem.

My function is quite simple:
1
2
3
4
5
6
void play_mp3() {

mciSendString(L"open \C:\Documents and Settings\Simon\Dokumenter\Musik\2pm\ type mpegvideo alias MediaFile", NULL, 0, NULL);
mciSendString(L"play Mediafile", NULL, 0, NULL);

}


Regards,

Simon H.A.
Aug 13, 2010 at 11:09am
Can you post the full error please.
Aug 13, 2010 at 11:21am
1
2
1>Shatronics_mp3_player.obj : error LNK2019: unresolved external symbol __imp__mciSendStringW@16 referenced in function "void __cdecl play_mp3(void)" (?play_mp3@@YAXXZ)
1>C:\Documents and Settings\Simon\Dokumenter\Elektronik\Programmering\VisualC++\Codes\Shatronics_mp3_player\Debug\Shatronics_mp3_player.exe : fatal error LNK1120: 1 unresolved externals


That's what it says.

Regards,

Simon H.A.
Aug 13, 2010 at 2:01pm
You need to link to WinMM.lib in the Platform SDK.
Aug 14, 2010 at 3:06pm
Thanks,
Now the code will compile. But it doesn't work.
I've added some changes, but it wont work.
The code is based on this site: http://www.gamedev.net/reference/articles/article2053.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
void play_mp3(TCHAR *filename) {

TCHAR command[MAX_PATH] = L"open \"";

_tcscat(command,filename);
_tcscat(command,L"\" type mpegvideo alias ");
_tcscat(command,filename);
command[_tcslen(command)] = 0;

mciSendString(command, NULL, 0, 0);
mciSendString(L"play mediafile", NULL, 0, 0);

}


The file direction is collected from another function that works perfectly, so the problem shouldn't be there.

Regards,
Simon H.A.
Last edited on Aug 14, 2010 at 3:14pm
Aug 15, 2010 at 6:20pm
I got the problem solved.
I just changed the alias to a more simple name such as "musicfile" and used that instead.
Now it works perfectly.

Thanks for your help kbw.

Regards,

Simon H.A.
Topic archived. No new replies allowed.