RaspberryPISourceInstall

Version 6 (coder, 25/04/2015 21:23)

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 1 coder
</code>
17 1 coder
</pre>
18 1 coder
19 1 coder
h2. Set up the Cross-compile Toolchain
20 1 coder
21 1 coder
This is the directory structure on the Linux machine:
22 1 coder
23 6 coder
<pre>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 1 coder
<pre>
35 6 coder
<code>$ cd rpi
36 1 coder
$ git clone git://github.com/raspberrypi/tools.git
37 1 coder
</code>
38 1 coder
</pre>
39 1 coder
40 1 coder
Copy /usr, /lib, and /opt/vc directory trees from the Pi (replace $PI with the IP address of the Pi):
41 1 coder
42 1 coder
<pre>
43 6 coder
<code>$ mkdir root
44 1 coder
$ cd root
45 1 coder
$ rsync -rl --delete-after --safe-links pi@$PI:/{lib,usr} .
46 1 coder
$ rsync -rl --delete-after --safe-links pi@192.168.2.PI:/opt/vc opt
47 1 coder
</code>
48 1 coder
</pre>
49 1 coder
50 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:
51 1 coder
52 1 coder
_root/usr/lib/arm-linux-gnueabihf/libpthread.so_:
53 1 coder
54 1 coder
<pre>
55 6 coder
<code>OUTPUT_FORMAT(elf32-littlearm)
56 1 coder
GROUP ( libpthread.so.0 libpthread_nonshared.a )
57 1 coder
</code>
58 1 coder
</pre>
59 1 coder
60 1 coder
_root/usr/lib/arm-linux-gnueabihf/libc.so_:
61 1 coder
62 1 coder
<pre>
63 6 coder
<code>OUTPUT_FORMAT(elf32-littlearm)
64 1 coder
GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux-armhf.so.3 ) )
65 1 coder
</code>
66 1 coder
</pre>
67 1 coder
68 1 coder
Fix some symlinks:
69 1 coder
70 1 coder
<pre>
71 6 coder
<code>$ cd root/usr/lib/arm-linux-gnueabihf/
72 1 coder
$ ln -s ../../../lib/arm-linux-gnueabihf/libm.so.6 libm.so
73 1 coder
$ ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 libdl.so
74 1 coder
</code>
75 1 coder
</pre>
76 1 coder
77 1 coder
Put the toolchain into the path ($RPI is the absolute path to your rpi directory):
78 1 coder
79 6 coder
<pre>
80 6 coder
<code>$ export PATH=$PATH:$RPI/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
81 6 coder
</code>
82 6 coder
</pre>
83 1 coder
84 1 coder
h2. Build libavg
85 1 coder
86 1 coder
<pre>
87 6 coder
<code>$ ./rpi-configure
88 1 coder
$ DESTDIR=$RPI/staging make -j6
89 1 coder
$ DESTDIR=$RPI/staging make install
90 1 coder
</code>
91 1 coder
</pre>
92 1 coder
93 5 coder
h2. Install on the Pi
94 1 coder
95 1 coder
Copy the compiled libavg to the Pi:
96 1 coder
97 1 coder
<pre>
98 6 coder
<code>$ cd staging
99 1 coder
$ rsync -au usr pi@$IP:/home/pi/Desktop
100 1 coder
</code>
101 5 coder
</pre>
102 1 coder
103 1 coder
*_On the Pi_*, copy libavg from the desktop to its final destination:
104 1 coder
105 1 coder
<pre>
106 6 coder
<code>$ sudo cp -R ~/Desktop/usr/* /usr
107 1 coder
</code>
108 1 coder
</pre>
109 1 coder
110 1 coder
h2. Run the tests
111 1 coder
112 1 coder
<pre>
113 6 coder
<code>$ cd /usr/local/share/python-libavg/test/
114 1 coder
$ python Test.py
115 1 coder
</code>
116 1 coder
</pre>
117 1 coder
118 5 coder
That's it! libavg should now be running on your Pi.