distcc User Manual: Cross compiling

Next Previous Contents

## 5. Cross compiling

Cross compilation means building programs to run on a machine with a different processor, architecture, or operating system to where they were compiled. distcc supports cross compilation, including teams of mixed-architecture machines, although some changes to the compilation commands may be required.

The compilation command passed to distcc must be one that will execute properly on every volunteer machine to produce an object file of the appropriate type. If the machines have different processors, then simply using `distcc cc` will probably not work, because that will normally invoke the volunteer's native compiler.

Machines with the same instruction set but different operating systems may not necessarily generate compatible .o files. Empirically it seems that the native FreeBSD compiler generates object files compatible with Linux for C programs, but not for C++. It may be a good idea to install a Linux cross compiler on BSD volunteers.

Different versions of the compiler may generate incompatible object files. This seems to be much more of a problem with C++ than with C, because the C++ ABI (application binary interface) has changed in recent years. If you will be building C++ programs, it may be a good idea to install the same version of `g++` on all machines.

Several different gcc configurations can be installed side-by-side on any machine. If you build gcc from source, you should use the `--program-suffix` configuration options to cause it to be installed with a name that encodes the gcc version and the target platform.

The recommended convention for the gcc name is target`-gcc-`version, such as `i686-linux-gcc-3.2`. GCC 3.3 will install itself under this name, in addition to target`-gcc` and, if it's native, `gcc-`version and `gcc`.

The compiler must be installed under the same name on the client and on every volunteer machine.

gcc also has `-b` and `-V` options to specify a target and version, but at the moment the gcc team recommend using a qualified compiler name instead.

For more information on cross-compiling, see Specifying Target Machine and Compiler Version in the gcc manual, and the gcc installation guide.

Next Previous Contents