RaspberryPISourceInstall

Version 7 (coder, 25/04/2015 21:26)

1 5 coder
h1. RaspberryPiSourceInstall
2 1 coder
3 5 coder
This page explains how to install the libavg developer version from github on a Raspberry Pi by cross-compiling. The process involves compiling libavg on a separate Linux machine. The benefit of this is that compiling on the Pi 2 takes around an hour, while cross-compiling takes a few minutes (The original Pi would finish in 4-6 hours or fail with an out of memory condition). The downside is that it's a bit harder to set up.
4 1 coder
5 5 coder
Alternatively, you can compile directly on the Pi by following the [[UbuntuSourceInstall]] directions.
6 1 coder
7 5 coder
h2. Install dependencies on the Pi
8 1 coder
9 5 coder
*_On the Pi_*, install the needed packages:
10 1 coder
11 1 coder
<pre>
12 1 coder
<code>$ sudo apt-get install git automake autoconf libtool libxml2-dev \
13 1 coder
libpango1.0-dev librsvg2-dev libgdk-pixbuf2.0-dev libavcodec-dev libavformat-dev \
14 1 coder
libswscale-dev libavresample-dev python-dev libboost-python-dev libboost-thread-dev g++ libSDL-dev \
15 1 coder
libxxf86vm-dev libdc1394-22-dev linux-libc-dev
16 7 coder
</code></pre>
17 1 coder
18 1 coder
h2. Set up the Cross-compile Toolchain
19 1 coder
20 1 coder
This is the directory structure on the Linux machine:
21 1 coder
22 7 coder
<pre>
23 7 coder
rpi
24 1 coder
    libavg        - the libavg source tree
25 1 coder
    root          - copy of the PI filesystem
26 1 coder
    rpi-tools     - the toolchain (compiler, linker, etc.) used to cross-compile
27 1 coder
    staging       - the compiled version of libavg that will be copied to the PI
28 1 coder
</pre>
29 1 coder
30 1 coder
31 1 coder
32 1 coder
*_On the Linux machine_*, download the crosscompile tools to rpi-tools:
33 1 coder
34 6 coder
<pre>
35 1 coder
<code>$ cd rpi
36 1 coder
$ git clone git://github.com/raspberrypi/tools.git
37 7 coder
</code></pre>
38 1 coder
39 1 coder
Copy /usr, /lib, and /opt/vc directory trees from the Pi (replace $PI with the IP address of the Pi):
40 1 coder
41 1 coder
<pre>
42 1 coder
<code>$ mkdir root
43 1 coder
$ cd root
44 1 coder
$ rsync -rl --delete-after --safe-links pi@$PI:/{lib,usr} .
45 1 coder
$ rsync -rl --delete-after --safe-links pi@192.168.2.PI:/opt/vc opt
46 7 coder
</code></pre>
47 1 coder
48 1 coder
Then, fix some system libraries so they don't contain references to absolute directories. Open the files in a text editor and change them. They are:
49 1 coder
50 1 coder
_root/usr/lib/arm-linux-gnueabihf/libpthread.so_:
51 1 coder
52 6 coder
<pre>
53 1 coder
<code>OUTPUT_FORMAT(elf32-littlearm)
54 1 coder
GROUP ( libpthread.so.0 libpthread_nonshared.a )
55 7 coder
</code></pre>
56 1 coder
57 1 coder
_root/usr/lib/arm-linux-gnueabihf/libc.so_:
58 1 coder
59 1 coder
<pre>
60 6 coder
<code>OUTPUT_FORMAT(elf32-littlearm)
61 1 coder
GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux-armhf.so.3 ) )
62 7 coder
</code></pre>
63 1 coder
64 1 coder
Fix some symlinks:
65 1 coder
66 1 coder
<pre>
67 6 coder
<code>$ cd root/usr/lib/arm-linux-gnueabihf/
68 1 coder
$ ln -s ../../../lib/arm-linux-gnueabihf/libm.so.6 libm.so
69 1 coder
$ ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 libdl.so
70 7 coder
</code></pre>
71 1 coder
72 1 coder
Put the toolchain into the path ($RPI is the absolute path to your rpi directory):
73 1 coder
74 6 coder
<pre>
75 6 coder
<code>$ export PATH=$PATH:$RPI/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
76 7 coder
</code></pre>
77 1 coder
78 1 coder
h2. Build libavg
79 1 coder
80 1 coder
<pre>
81 6 coder
<code>$ ./rpi-configure
82 1 coder
$ DESTDIR=$RPI/staging make -j6
83 1 coder
$ DESTDIR=$RPI/staging make install
84 7 coder
</code></pre>
85 1 coder
86 5 coder
h2. Install on the Pi
87 1 coder
88 1 coder
Copy the compiled libavg to the Pi:
89 1 coder
90 6 coder
<pre>
91 1 coder
<code>$ cd staging
92 1 coder
$ rsync -au usr pi@$IP:/home/pi/Desktop
93 7 coder
</code></pre>
94 1 coder
95 1 coder
*_On the Pi_*, copy libavg from the desktop to its final destination:
96 6 coder
97 1 coder
<pre>
98 1 coder
<code>$ sudo cp -R ~/Desktop/usr/* /usr
99 7 coder
</code></pre>
100 1 coder
101 1 coder
h2. Run the tests
102 1 coder
103 6 coder
<pre>
104 1 coder
<code>$ cd /usr/local/share/python-libavg/test/
105 1 coder
$ python Test.py
106 7 coder
</code></pre>
107 1 coder
108 5 coder
That's it! libavg should now be running on your Pi.