Wednesday 23 January 2013

Raspberry pi development part 2

Compiling a simple hello world program is all very well but as soon as we want to compile something interesting (for example something using GLES or x-windows) then we run into the problem that we don't have the required header files or libraries. We can't use the libraries from the host system of course because they are for an x86 PC and not an ARM based raspberry pi.
One solution is to copy the header and library files over to the host system. The directories we need are /usr/include, /usr/lib, /opt/vc/include and /opt/vc/lib

rsync to the rescue

As both system as linux, we can use rsync. rsync is a utility that is used to keep two directories in sync ... exactly what we want. To begin with we need to install rsync on the pi as it is not installed in the base image.
ssh to the pi and execute the following command to do that:

sudo apt-get install rsync

One done, execute the following commands on the host linux system (changing 192.168.0.114 to the address of your raspberry pi).

cd ~/rpi

mkdir root/opt
mkdir root/usr

rsync -e ssh -lr pi@192.168.0.114:/usr/includeroot/usr
rsync -e ssh -lr pi@192.168.0.114:/usr/lib root/usr

mkdir root/opt
mkdir root/opt/vc

rsync -e ssh -lr pi@192.168.0.114:/opt/vc/include root/opt/vc
rsync -e ssh -lr pi@192.168.0.114:/opt/vc/lib root/opt/vc


This will synchronise the /usr/include and /usr/lib directories from the raspberry pi over to ~/rpi/root on the host system. Whenever you update the raspberry pi or add new packages, run the rsync commands again to make sure that the host is up to date.


No comments:

Post a Comment