Posted: Mon Dec 26, 2011 7:36 Post subject: [Tutorial] Building ShairPort from scratch!
Quote:
If you wish to make an apple pie from scratch, you must first invent the universe.
— Carl Sagan
ShairPort is an open source implementation of the RAOP protocol. It allows AirPlay clients (iTunes, iPods, etc.) to stream music through your attached speakers.
The goal of this guide is to build a ShairPort package and deploy it on DD-WRT.
Step 0: Prerequisites
We're going to build inside a virtual machine. Setting up the virtual machine is outside the scope of this guide. I used Debian 6.0.3 for amd64.
You should also have Optware installed. I don't care for Optware, the Right Way because it installs so much crap on your router. I've attached a simplified script you may use that should be exactly what you need.
Both OTRW and my script install important kernel drivers for audio output over USB. You should also appropriately configure USB support; this too is out of scope.
Step 1: Building the toolchain
Now we will build Optware inside the VM. The basis for this part is "Add a Package to Optware" though I hit some bumps.
As the page says, you'll need to install a handful of packages:
Now check out the Optware source and prepare our dd-wrt build directory:
Code:
# cd ~ && svn co http://svn.nslu2-linux.org/svnroot/optware/trunk optware
# cd optware && make ddwrt-target
At this point Optware has created a directory called 'downloads' where it will cache downloaded source bundles. Since Optware requires some packages that aren't available from their default download locations, we can put files here to prevent a build error:
I've attached a Makefile for building ShairPort. It is probably not up to the same standards as other Optware build scripts, but it should work. Be sure to put it in optware/make not optware/ddwrt/make, and rename it to "shairport.mk". The forum does not allow me to upload with the correct extension.
However, esound, a dependency if libao and hence of ShairPort, does not compile correctly because it uses a variable named $echo which is not defined. So, we'll modify the esound Makefile to fix this.
Edit optware/make/esound.mk and find this line:
Code:
$(PATCH_LIBTOOL) $(@D)/libtool
After it, add these two. Indent the 'sed' line with one tab (omitted below due to phpBB).
Code:
sed -i -e '1 a\
echo=/bin/echo' $(@D)/libtool
With that fix, compiling ShairPort is as easy as this:
Code:
# make shairport-ipk
When finished, it will have built a .ipk in optware/ddwrt/builds named something like "shairport_0.05-1_mipsel.ipk".
Step 3: Building D-Bus
The D-Bus that currently builds with Optware does not work on dd-wrt due to the -fPIE compiler flag, as noted (incorrectly) on "Adventures with DD-WRT Part 5".
I'm working on compiling this properly. For now, elsewhere on the forum you can find a prebuilt .ipk with a fixed D-Bus.
shairport.txt
Description:
Makefile for ShairPort. Rename to "shairport.mk" after download.
Next we need to add our daemon user and group, per "Adventures with DD-WRT Part 5". N.B.: These will be wiped on reboot, so you should configure a script to do this automatically.
Next we will install the Avahi daemon init.d script, once again courtesy of "Adventures with DD-WRT Part 5". Drop the attached script in /opt/etc/init.d/ and rename it to "S21avahi-daemon" (removing the extension). Don't forget to change its permissions:
I'm trying to compile Shairport using these instructions but need some help.
When I try "make shairport-ipk" I'm getting a compile error related to gcc/collect2.c
"declared with attribute error: open with O_CREAT in second argument
needs 3 arguments"
I've googled this error and the suggestion is to edit the collect2.c file and add the extra argument, however the file gets replaced and I'm not sure where its coming from or how to make my edit stick.
I'm using the latest version of Ubuntu (also tried Debian but ran into a different error). Any help is appreciated. Thanks
Code:
gcc -g -O2 -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long -DHAVE_CONFIG_H gcov.o intl.o version.o ../libiberty/libiberty.a -o gcov
gcc -g -O2 -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long -DHAVE_CONFIG_H -I. -I. -I/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc -I/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/. -I/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/config -I/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/../include \
-DTARGET_MACHINE=\"armv5b-softfloat-linux\" \
-c /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c -o collect2.o
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c: In function ânoticeâ:
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:362:1: warning: traditional C rejects ISO C style function definitions [-Wtraditional]
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c: In function âfatal_perrorâ:
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:374:1: warning: traditional C rejects ISO C style function definitions [-Wtraditional]
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c: In function âfatalâ:
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:392:1: warning: traditional C rejects ISO C style function definitions [-Wtraditional]
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c: In function âerrorâ:
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:408:1: warning: traditional C rejects ISO C style function definitions [-Wtraditional]
In file included from /usr/include/fcntl.h:252:0,
from /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/system.h:208,
from /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:30:
In function âopenâ,
inlined from âcollect_executeâ at /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:1575:20:
/usr/include/i386-linux-gnu/bits/fcntl2.h:51:24: error: call to â__open_missing_modeâ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
make[2]: *** [collect2.o] Error 1
make[2]: Leaving directory `/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/build-gcc-core/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/build-gcc-core'
make: *** [/home/user1/optware/optware/toolchain/crosstool/.built] Error 2
I attempt to edit line 1575 of collect2.c
Code:
Change: redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT);
To: redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, 0777);
Rerun "make shairport-ipk" but get the same error.
In file included from /usr/include/fcntl.h:252:0,
from /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/system.h:208,
from /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:30:
In function âopenâ,
inlined from âcollect_executeâ at /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:1575:20:
/usr/include/i386-linux-gnu/bits/fcntl2.h:51:24: error: call to â__open_missing_modeâ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
make[2]: *** [collect2.o] Error 1
make[2]: Leaving directory `/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/build-gcc-core/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/build-gcc-core'
make: *** [/home/user1/optware/optware/toolchain/crosstool/.built] Error 2
I attempt to edit line 1575 of collect2.c
Code:
Change: redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT);
To: redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, 0777);
Rerun "make shairport-ipk" but get the same error.
Hello! to fix this error need todo:
edit optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c
Code:
- redir_handle = open (tracefn, O_CREAT|O_TRUNC|O_WRONLY);
+ redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR|S_IWUSR);
makeing chmod 0400 to optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c
PS worked on ubuntu 12
Last edited by tjma on Fri Dec 14, 2012 13:02; edited 1 time in total
The collect2.c file keeps getting replaced and I can't figure out how to stop it from doing it. I attempted to change ownership of the file and chmod-ing it to read only, but it still gets replaced.
I also attempted to download the gcc lib (untar, modify file, and retar) to have a local cache version, but that didn't work either. I'm obviously doing something wrong.
The collect2.c file keeps getting replaced and I can't figure out how to stop it from doing it. I attempted to change ownership of the file and chmod-ing it to read only, but it still gets replaced.
I also attempted to download the gcc lib (untar, modify file, and retar) to have a local cache version, but that didn't work either. I'm obviously doing something wrong.
Can you share your compiled packaged? Thanks
if you are using ubuntu it can help you (see attach) it is my collect2.c with revisions.
If it can't help, sorry, I don't know any more
PS I had a mistake in the code, sorry, edited prev message
collect2.c
Description:
you must change the rights to 0400 before compiling
I understand the changes I need to make to the collect2.c file. My changes just isn't sticking, meaning the file get replaced eventhough I used chmod 0400.
Can you please share this file - "shairport_0.05-1_mipsel.ipk"?
Wow, this is EXACTLY what I have been looking for. I want to use my Belkin N300 router as an Airport device to stream music from my Ipad and Ipod (and Android using iRemote). Has anyone else had success with this procedure?
Well, I have been working on this but am failing in compiling the shairport_0.05-1_mipsel.ipk. Would anyone who has succeeded in creating this ipk be willing to share it with me?
Joined: 21 Sep 2007 Posts: 373 Location: pittsburgh pa
Posted: Sun Mar 24, 2013 17:57 Post subject:
i've been part of the communication over on that forum as well (Mike M)
your "buffer must be between 30-512" message means you need to specify the buffer (-b) option:
shairport -a "Your_Desired_Name" -b 282 -d
read the entire thread over there to see how to get everything up and running, all the info is there.
I tried experimenting with different buffer sizes, anything less than 250ish it will be choppy when first starting then smooth out. 282 gives good results, and about 1-2 seconds of lag when changing volume/switching songs.