How to build shairport on Mac OS X

Speaker

Building and running shairport on Mac OS X might seem like an academic exercise, still it is useful if you want to stream music from a iOS device to your Mac. Assuming you have macport and XCode installed on your machine, the process is quite straightforward: just install the needed packages, download the source code, compile it and run it.


Compiler et exécuter shairport sur Mac OS X peut sembler être un exercice académique, cela reste néanmoins utile si on veut streamer de la musique depuis un appareil qui tourne sous iOS vers votre Mac. Pour peu que vous ayez installé macport et XCode sur votre machine, c’est très simple  : il suffit de télécharger les librairies nécessaires, le code source, compiler le programme et l’exécuter.


Shairport auf Mac OS X zu kompilieren kann wie eine Akademische Übung scheinen, trotzdem kann das nützlich sein die Musik von einem iOS device auf einem OS X Computer hören. Sobald Sie XCode und macport auf ihrem Komputer installiert haben, ist es sehr einfach: mann muss nur die benötigte libraries installieren, den source code down zu loaden und das alles kompilieren und exekutieren.

sudo port install git-core
sudo port install libao
sudo port install p5-io-socket-inet6
sudo port install p5-libwww-perl
sudo port install p5-crypt-openssl-rsa
git clone https://github.com/albertz/shairport.git
cd shairport
make
perl shairport.pl

Additional instructions can be found in the INSTALL.md file, in particular to start the binary as a dæmon. On thing I had to change in the configuration was to add the following lines to the org.mafipulation.shairport.plist file, so that the script it picked the port version of perl (the one with the additional libraries). I also made the file point directly to the binary in the directory where I build it.

This worked like a charm under Mac OS X 10.6.7, with the sound coming from my iPhone, for instance from Buddha Machine. Now if only this could run this on my PS3, that would be awesome…
Des instructions additionelles (en anglais) sont disponibles dans le fichier INSTALL.md. Une chose que j’ai du changer, c’est ajouter les lignes suivantes au fichier org.mafipulation.shairport.plist afin que le script utilise la version port de perl, celle pour laquelle toutes les librairies additionnelles ont été installées. J’ai aussi changé le chemin d’accès du binaire pour utiliser directement la version que j’ai compilé.

Le tout fonctionne parfaitement sous Mac OS X 10.6.7 avec la musique venant de mon iPhone, par exemple depuis Buddha Machine. Maintenant si seulement ce code pouvait tourner sur ma PS3, cela serait génial…
Zusätzliche Einleitungen (auf English) kann man im INSTALL.md file finden. Eine Sache, dass ich ändern müsste, war die folgenden Zeilen im org.mafipulation.shairport.plist File änderen, so das port die Lokale version von perl brauchte. Die selbe version wofür wir alle diese Libraries installiert haben. Ich habe auch den Path verändert um direkt die Binärdatei die wir Kompiliert haben, zu brauchen. Alles funktioniert perfekt auf Mac OS X 10.6.7: die Musik von Buddha Machine
meines iPhone kann ich auf dem Laptop hören. Jetzt wäre es geil, wenn ich dieses Program auf meiner PS3 laufen lassen könnte…

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>org.mafipulation.shairport</string>
    <key>RunAtLoad</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/wiesmann/Projects/personal/shairport/shairport.pl</string>
        <string>--apname</string>
        <string>わがまま</string>
    </array>
    <key>EnvironmentVariables</key>
    <dict>
    <key>PATH</key>
    <string>/opt/local/bin:/opt/local/sbin:/opt/local/sbin:/opt/local/bin:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin</string>
    </dict>
</dict>
</plist>

18 thoughts on “How to build shairport on Mac OS X”

  1. Works perfect here, thx. One question: If I want to transfer this to another machine (have a lot of them) – what packages are required for that? Everything but Xcode and compiling the source code, right?

  2. @Minimum, in the first case, it seems you did not have git installed. In the second case, I suspect you had another port session running elsewhere, or that did not terminate properly. Anyways, you should not need avahi on mac os x, I would check that port installed stuff appears in your PATH…

  3. @minimum

    uninstall avahi but run this command first:
    sudo launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist
    then run the app.

  4. @Thias, @Whacko Weird.

    @Whacko @Thias Thank you for your response! I appriciate your advice very much but unfortunately I have not yet reached that kind of state of mind which would allow me to understand what is it exacly you are trying to tell me (I’m new to Terminal).
    I followed the exact same tutorial and installed shairport on my G4 Cube and everything went smooth as butter with some exceptions like I have no idea where did I install shairport iteslf (I wanted to modify the shairport.pl to change the name and add a password. Like it said in the readme).
    I was also left wondering if there is any way to run it in the background every time I boot my machine like startup items.
    As stated in previous posts I have trouble installing shairport on my primary intel-iMac (screenshots provided). I get what you are saying, but I have no idea how to do stuff like uninstall avahi. I don’t even know if it’s a perl module or not. I have my pen and paper activated and my eyes open wide, so I’m listening carefully to what you guys are saying, but I would very much appriciate if you could be a little more specific.

    Whilst writing this response I noticed that while streaming to both my main iMac and the G4 Cube the music occasionally gets out of sync occasionally. I’m not transferring anything over LAN at the moment, so I don’t know what could be the cause of lag. Could it be that shairport simply does not support syncing? Could it be that the Cube is just too slow to handle shairport?

    Again, sorry for my incompetence and thank you for your responses.

    ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
    I wrote a response, but it didn’t get through and now It says that I double-posted the comment… Here it is: http://cl.ly/071q0t280r1q1q0j100r (Thias: I inlined the missing comment).

    ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

  5. I Have CMus installed from Homebrew, and there is no “brew” for Shairport.

    Crazy question: If I wanted to send Cmus to my AirPort Express, would Shairport be the way to go?

  6. I seem to get this error on Mountain Lion:

    Any ideas?

    Listening…
    Failed to create client object: Daemon not running
    Avahi publishing failed! Do you have avahi-publish-service on your PATH? at shairport.pl line 66, line 23.

  7. Full mountain lion instructions

    Install this: http://www.macports.org/install.php
    Install this: https://developer.apple.com/xcode/
    Once xcode is installed open it goto preferences then install command line tools under downloads

    Open terminal then use these commands:

    sudo port install git-core
    sudo port install libao
    sudo port install p5-io-socket-inet6
    sudo port install p5-libwww-perl
    sudo port install p5-crypt-openssl-rsa
    git clone https://github.com/albertz/shairport.git
    sudo cpan install Net::SDP
    cd shairport
    make
    perl shairport.pl

    Want to make it start up on boot? DO NOT COPY ANYTHING FROM # FORWARD PER COMMAND IT COMMENTED OUT FOR A REASON!

    $ cp hairtunes shairport.pl /usr/local/bin
    $ vi /usr/local/bin/shairport.pl # change the path of hairtunes from ./hairtunes to /usr/local/bin/hairtunes
    $ mkdir -p ~/Library/LaunchAgents
    edit org.mafipulation.shairport.plist and change apname string to whatever name you want it to be default=RJ
    $ cp org.mafipulation.shairport.plist ~/Library/LaunchAgents/
    $ launchctl load org.mafipulation.shairport.plist
    $ launchctl unload org.mafipulation.shairport.plist # (to remove)

  8. Thanks for the reply dubz. I still get the same error:

    macmini$ perl /usr/local/bin/shairport.pl
    listening…
    Failed to create client object: Daemon not running
    Avahi publishing failed! Do you have avahi-publish-service on your PATH? at /usr/local/bin/shairport.pl line 65, line 23.

    I’ve installed all as listed and ran make. Any ideas?

  9. I used homebrew. You have to install dbus: brew install dbus

  10. These instructions worked pretty well for me. I had to install pkgconfig:

    sudo port install pkgconfig

    in order for the makefile to work, since it uses the package commands. And I had to

    sudo cpan install Net::SDP

    cpan itself was broken until I moved ~/.cpan to ~/.cpan.bak.

    But then it worked!

    thanks!

Leave a Reply to WhackoCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.