Version 1/27 - Next ยป - Current version
coder, 25/04/2015 20:00


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 takes around an hour, while cross-compiling takes a few minutes. The downsied is that it's a bit harder to set up.

Alternatively, you can compile directly on the PI by following the UbuntuSourceInstall directions.

Install dependencies on the PI

On the PI, install the needed packages:

$ sudo apt-get install git automake autoconf libtool libxml2-dev \
libpango1.0-dev librsvg2-dev libgdk-pixbuf2.0-dev libavcodec-dev libavformat-dev \
libswscale-dev libavresample-dev python-dev libboost-python-dev libboost-thread-dev g++ libSDL-dev \
libxxf86vm-dev libdc1394-22-dev linux-libc-dev

Set up the Cross-compile Toolchain

This is the directory structure on the Linux machine:

    libavg        - the libavg source tree
    root          - copy of the PI filesystem
    rpi-tools     - the toolchain (compiler, linker, etc.) used to cross-compile
    staging       - the compiled version of libavg that will be copied to the PI

On the Linux machine, download the crosscompile tools to rpi-tools:

$ cd rpi
$ git clone git://

Copy /usr, /lib, and /opt/vc directory trees from the PI (replace $PI with the IP address of the PI):

$ mkdir root
$ cd root
$ rsync -rl --delete-after --safe-links pi@$PI:/{lib,usr} .
$ rsync -rl --delete-after --safe-links pi@192.168.2.PI:/opt/vc opt

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:


GROUP ( libpthread_nonshared.a )


GROUP ( libc_nonshared.a  AS_NEEDED ( ) )

Fix some symlinks:

$ cd root/usr/lib/arm-linux-gnueabihf/
$ ln -s ../../../lib/arm-linux-gnueabihf/
$ ln -s ../../../lib/arm-linux-gnueabihf/

Put the toolchain into the path ($RPI is the absolute path to your rpi directory):

$ export PATH=$PATH:$RPI/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin

Build libavg

$ ./rpi-configure
$ DESTDIR=$RPI/staging make -j6
$ DESTDIR=$RPI/staging make install

Install on the PI

Copy the compiled libavg to the PI:

$ cd staging
$ rsync -au usr pi@$IP:/home/pi/Desktop

On the PI, copy libavg from the desktop to its final destination:

$ sudo cp -R ~/Desktop/usr/* /usr

Run the tests

$ cd /usr/local/share/python-libavg/test/
$ python

That's it! libavg should now be running on your PI.