Version 8 (modified by 12 years ago) (diff) | ,
---|
Cross-compiling Synapse for raspberry (ARM) and other architectures
This is a quick howto on how i cross compiled synapse for the raspberrypi, using qemu to emulate the arm cpu architecture. This is the least tricky methode to cross compile, but also the slowest.
I used arch linux on my host system and debian on the rasp.
Learn your host system how to handle arm binaries
1. Steal a statically compiled qemu-arm from some distro:
its a shame archlinux doesnt have a static qemu :(
[root@lab1 tmp]# cd /tmp [root@lab1 tmp]# mkdir qemu [root@lab1 tmp]# cd qemu [root@lab1 qemu]# dpkg -x /home/psy/Downloads/qemu-user-static_1.1.2+dfsg-2_amd64.deb . [root@lab1 qemu]# cp usr/bin/qemu-*-static /usr/bin
2. learn your kernel how to handle arm binaries
Create a file called /usr/share/binfmts/qemu-arm:
[root@lab1 binfmts]# cat /usr/share/binfmts/qemu-arm package qemu interpreter /usr/bin/qemu-arm-static magic \x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00 mask \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff [root@lab1 binfmts]# update-binfmts --import
Set up the build environment
1. copy the rootfilesystem from your raspberry
We just copy the whole rootfs, so we have an exact copy of the environment we want to cross compile for:
[root@lab1 psy]# rsync -ax root@192.168.13.238:/ rasprootfs root@192.168.13.238's password: ....
2. entering the build environment
The only thing you have to do to be able to enter the environent is copy qemu-arm-static into it:
[root@lab1 psy]# cp /usr/bin/qemu-arm-static rasprootfs/usr/bin/ [root@lab1 psy]# export QEMU_CPU=arm1176 [root@lab1 psy]# chroot rasprootfs/ [rasproot] root@lab1:/# arch armv6l
w000h...now we can chroot to the local raspberry environment and start to compile stuff!
note that arch says armv61 and NOT armv7l. (if it doesnt you forgot to set the environment variable)
compiling and installing synapse =
1. install dependencies neccesary to compile synapse
Inside the chroot do this:
root@lab1:~/Synapse# apt-get install libboost-all-dev cmake libcurl4-openssl-dev liboauth-dev libvlc-dev Reading package lists... Done Building dependency tree Reading state information... Done (....... takes a while)
2. clone the source tree
root@lab1:~# git clone git://github.com/psy0rz/Synapse.git Cloning into 'Synapse'... remote: Counting objects: 4533, done. remote: Compressing objects: 100% (1258/1258), done. remote: Total 4533 (delta 3311), reused 4429 (delta 3207) Receiving objects: 100% (4533/4533), 2.04 MiB | 835 KiB/s, done. Resolving deltas: 100% (3311/3311), done.
wow...even while emulated git STILL is superquick! git is awesome :)
3. compile it
root@lab1:~# cd Synapse/ root@lab1:~/Synapse# cmake . -- The C compiler identification is GNU 4.6.3 ...... root@lab1:~/Synapse# make -j 4 Scanning dependencies of target test_http_json Scanning dependencies of target pl_dir .....takes forever the first time...