I tried to com­pile mpd for Win­dows using Cyg­win. After adding some workarounds (add fake_getaddrinfo.h, check http://musicpd.org/mantis/view.php?id=1566) I was able to com­pile mpd. But when I tried to start it, mpd failed:

1
2
3
4
5
6
7
8
9
$ ./mpd –no-daemon –std­out –ver­bose
bind­ing to any address
flush­ing warn­ing mes­sages
done flush­ing warn­ing mes­sages
cur­rent locale is “C“
set­ting filesys­tem charset to ISO-8859–1
setF­sCharset: fs charset is: ISO-8859–1
read­ing DB
Bad sys­tem call

Mpd uses shared mem­ory – to use shared mem­ory under Cyg­win you need the cygserver run­ning. A “$ cygserver-config” did the trick and installed a new ser­vice called cygserver. Now export the impor­tant vari­able CYGWIN:

1
$ export CYGWIN=server

And retry to start mpd:

1
2
3
4
5
6
7
8
9
$ ./mpd.exe –std­out –ver­bose
bind­ing to any address
flush­ing warn­ing mes­sages
done flush­ing warn­ing mes­sages
cur­rent locale is “C“
set­ting filesys­tem charset to ISO-8859–1
setF­sCharset: fs charset is: ISO-8859–1
read­ing DB
open­ing pid file  1 [main] mpd 1736 C:cygwinhomempxmpd-testmpd.exe:    *** fatal error — MapViewOf­FileEx (0x19030000),    Win3 2 error 6.  Ter­mi­nat­ing.  68 [main] mpd 676 fork: child 1736 — died    wait­ing for dll load­ing, errno 11 prob­lems fork’ing for daemon!

The same error also occurs when you start mpd with the –no-daemon flag, use mpc and play a file.

1
2
3
4
5
6
7
8
9
10
11
playlist: play 0:“Daft Punk/Daft Punk Alive 2007/7. Too Long.mp3” 
debug play­erInit: 10 
debug play­erInit: 20  
1 [main] mpd 1216 C:cygwinhomempxmpd-testmpd.exe:    
*** fatal error — MapViewOf­FileEx (0x19030000),    
Win32 error 6.  Ter­mi­nat­ing.  2 [main] mpd 2576 fork:
child 1216 — died wait­ing for dll load­ing, errno 11 
debug play­erInit: 30  (pid: 0/-1)
debug play­erInit: 31
player Prob­lems fork()‘ing
playlist: stop

I traced down the error in the file player.c, source:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sta­tic int play­erInit(void){
  …
  LOG(” debug play­erInit: 10n”);   
  pid = player_pid;   
  if (pid > 0) {
    kill(pid, SIGCONT);       
    pc->wait = 0;       
    return 0;   
  }
  LOG(” debug play­erInit: 20n”);   
  player_pid = fork();     
  «CRASHLOG(” debug play­erInit: 30  (pid: %i/%i)n”, pid, player_pid);       
  blockSig­nals();
  LOG(” debug play­erInit: 31 n”);           
  if (player_pid==0)
  …

I checked my Win­dows event log:
The descrip­tion for Event ID ( 0 ) in Source ( Cyg­win ) can­not be found. The local com­puter may not have the nec­es­sary reg­istry infor­ma­tion or mes­sage DLL files to dis­play mes­sages from a remote com­puter. The fol­low­ing infor­ma­tion is part of the event: cygserver: WARNING: Group not found in /etc/passwd! Using gid –1!.

And cor­rected this error (“$ mkgroup –l > /etc/group” and “$ mkpasswd –l > /etc/passwd”) – but mpd still refused to work. I updated Cyg­win to the lat­est dev snap­shot – still the same error. Looks like a Cyg­win Bug to me.

** Edit (21.11.07): This Cyg­win error has been fixed in the cur­rent Snap­shot release (cygwin1-20071108.dll.bz2), so mpd runns fine under Windows… **