Gernot Walzl


Cross compilation creates executable binary code for a target architecture that differs
from the host architecture. For example, the compiler runs on x86_64 (common desktop PC)
and produces output for armv7l (Raspberry Pi).


The root filesystem of the target system is called sysroot.
It contains header files and precompiled libraries to link against.

The official Raspbian image can be mounted and used as sysroot.

mkdir -p raspberrypi/sysroot
sudo 2018-04-18-raspbian-stretch.img 2 raspberrypi/sysroot

Absolute links need to be fixed to point to files inside sysroot.

sudo raspberrypi/sysroot

As an alternative option, the filesystem of a remote target can be mounted over network
using sshfs.

sshfs pi@raspberrypi:/ raspberrypi/sysroot -o transform_symlinks


The cross-compiling toolchain for the Raspberry Pi is on GitHub.

mkdir raspberrypi
cd raspberrypi
git clone
export PATH="$PATH:$HOME/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"


The following example cross-compiles the base module of Qt for Raspbian.

cd qtbase
./configure -opensource -confirm-license \
  -device linux-rasp-pi2-g++ \
  -device-option CROSS_COMPILE=arm-linux-gnueabihf- \
  -sysroot "$HOME/raspberrypi/sysroot"
make install   # installs to the given sysroot

External links for further information

CONTENT.html source 2022-05-22 2.2 KB source 2016-02-23 709 B
by Gernot Walzl
This script mounts a partition contained by an image of an sd card.
The image can be read using dd: source 2016-02-23 1.2 KB
by Gernot Walzl
Many root filesystems for embedded linux devices contain absolute links.
When such an image is mounted into the filesystem,