Sign up ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I have read How to build a GCC 4.7 toolchain for cross-compiling? and have successfully built a simple test program that works on my RPi.

To do this, I had to run arm-unknown-linux-gnueabi-gcc hello.c -o hello on my x86 desktop and scp the executable to my RPi. This is slow and a hassle. I would rather control the compilation from my RPi.

I have read about distcc, which can be used to distribute the compilation from one machine to another.

How do I install this? I have both Debian/Ubuntu and Arch Linux desktops and both OSs installed on SD cards.

share|improve this question
I've been waiting for someone that's not me to post this question. I really didn't want to do it. Nice work. –  Jivings Jun 27 '12 at 16:20
export DISTCC_VERBOSE=1 Thanks for this ! It is what I'm looking for to debbug my distcc toolchain –  user3462 Nov 27 '12 at 13:06

1 Answer 1

up vote 10 down vote accepted

These instructions assume you have a working cross-compiler on the slave. Please read How to build a GCC 4.7 toolchain for cross-compiling? if you haven't. It is also useful to have make installed on the master.


First, we must install distcc. We shall use the prebuilt packages supplied by the operating systems' package management systems, but you are free to install from source if you want!


sudo apt-get install distcc


sudo pacman -S distcc


Slave - Debian/Ubuntu

TODO: Is this the same for Arch? If not, how do we configure Arch?

We need to adjust the settings in /etc/default/distcc. In your favourite editor, open it as root; I ran sudo vim /etc/default/distcc.

You need to change STARTDISTCC, ALLOWEDNETS and LISTENER. Assuming you have your master and slave are on the same subnet and that subnet is, they should be set to


Furthermore, you should add the path to your compiler. I did this by adding the following line


Note The daemon on the slave will be running as the distccd user, so ensure the appropriate permissions are configured on your executables; I gave everyone permission to execute.

Run the daemon - it would normally be started at boot - by running

sudo service distcc start

Master - Arch

TODO: Is this the same for Debian? If not, how do we configure Debian?

Open ~/.distcc/hosts in your favourite text editor and add the IP address of the Slaves. My hosts file consisted of a single line, which read

Note It might be a good idea to assign a static IP address to your slave, otherwise you will have to change this file whenever the IP address changes.


All going well, you should be able to use distcc quite simply. For example, to compile hello.c to hello.o, run

distcc arm-unknown-linux-gnueabi-gcc    -c -o hello.o hello.c

Example: Hello World!

I set up a simple example in my home directory, which consisted of 2 files.

# file: Makefile
hello.o: hello.c
hello: hello.o

# file: hello.c
#include <stdio.h>

int main() {
  printf("Hello World!\n");
  return 0;

Running make hello will compile locally; you should do this as a quick test first. Go on, I'll wait.

Running make hello CC="distcc arm-unknown-linux-gnueabi-gcc" will run a distributed compilation.

Note The preprocessing and the linking still happens on the RPi.


It took me a while to get this working correctly, and the best debugging tool I found was a simple environment variable. If you


the distcc client will output loads of useful information.

This is a long post, so any feedback would be gratefully received. I hope I remembered all the steps!

share|improve this answer
Excellent answer. I am going to bookmark this for my RPi development. –  Jivings Jun 27 '12 at 16:21
@AlexChamberlain Distcc now supports "pump mode" which allows it to distribute the preprocessing as well. –  teraquendya Jun 27 '12 at 20:43
@teraquendya They do indeed, I haven't got around to posting details about this yet. I want to make sure I've got everything right without pump mode first. –  Alex Chamberlain Jun 27 '12 at 21:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.