sudo rpi-update
In a old post I wrote where to get and how to use a gcc cross toolchain to compile from a pc host to a raspberry target.
Here how to use distcc
on target raspberry (and distccd
on pc host) to build faster over a distributed network (a cross toolchain installed on network nodes is a prerequisite).
Assuming the pc have ip address 192.168.1.210
and pi 192.168.1.2
, on the host:
pc host $ cd $HOME/toolchains/raspberry-pi
pc host $ export PATH=$PWD/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/libexec/gcc/arm-linux-gnueabihf/4.8.3:$PATH
pc host $ export PATH=$PWD/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/bin:$PATH
pc host $ distccd --daemon --jobs 8 --allow 192.168.1.2 --verbose --log-stderr --no-detach
Using --no-detach
the process will sleep listening for connections and eventually log on stdout, on pi:
pi target $ export DISTCC_HOSTS="192.168.1.210"
pi target $ CC="distcc gcc" CXX="distcc g++" cmake -DCMAKE_BUILD_TYPE=release
pi target $ make -j4
DISTCC_HOSTS
support more machines (see distcc documentation for more options) Here I’m using --jobs 8
on distccd side and only -j4
on distcc side. The drawbacks are that not all packages support CC
and CXX
variables from env correctly, as not every package support a parallel build.
An alternative to pass CC CXX
is to use the environment PATH
variable (export PATH=/usr/lib/ccache:/usr/lib/distcc:$PATH
) to specify a directory which should contain symlinks (eg: gcc -> ../../bin/ccache
or clang++-4.0 -> ../../distcc
), the name of the symlink should match the invoked compiler and point to the real executables of ccache and distcc.
reference: New script to compile TP-Link TL-WN725N version 2 lwfinger driver in Raspbian
ID 0bda:8179 Realtek Semiconductor Corp.
~root:
apt-get install lighttpd mysql-server php5-common php5-cgi php5 php5-mysql
lighty-enable-mod fastcgi-php
service lighttpd force-reload
chown www-data:www-data /var/www
chmod 775 /var/www
usermod -a -G www-data pi
~pi:
newgrp www-data # needed only once after usermod
echo '<?php phpinfo(); ' > /var/www/index.php
download tools-master.zip
cd /tmp
# I'm using i686 the directory depend on host architecture (32/64 bit)
unzip ~/Downloads/tools-master.zip "tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/*"
mv tools-master/arm-bcm2708 ~/toolchains/raspberry-pi/
export PATH=$HOME/toolchains/raspberry-pi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH
test.cpp:
#include <iostream>
int main(int argc, char **argv)
{
std::cout << "hello world" << std::endl;
return 0;
}
run test on rpi:
arm-linux-gnueabihf-g++ -Wall -O2 -o test test.cpp
scp test pi@rpi-host:/tmp
ssh pi@rpi-host
/tmp/test
$ hello world