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

The root filesystem of the target system is called <em>sysroot</em>.<br />
It contains header files and precompiled libraries to link against.
The official <a href="https://www.raspberrypi.org/downloads/raspbian/" target="_blank">Raspbian image</a>
can be mounted and used as sysroot.</p>
<pre><code class="language-bash">mkdir -p raspberrypi/sysroot
sudo mount_img.sh 2018-04-18-raspbian-stretch.img 2 raspberrypi/sysroot
Absolute links need to be fixed to point to files inside sysroot.
<pre><code class="language-bash">sudo xcompile_fix_links_img.sh raspberrypi/sysroot
As an alternative option, the filesystem of a remote target can be mounted over network<br />
using <em>sshfs</em>.
<pre><code class="language-bash">sshfs pi@raspberrypi:/ raspberrypi/sysroot -o transform_symlinks

<p>The cross-compiling toolchain for the Raspberry Pi is on
<a href="https://github.com/raspberrypi/tools" target="_blank">GitHub</a>.</p>
<pre><code class="language-bash">mkdir raspberrypi
cd raspberrypi
git clone https://github.com/raspberrypi/tools
export PATH="$PATH:$HOME/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"

<p>The following example cross-compiles the base module of
<a href="https://download.qt.io/" target="_blank">Qt</a> for Raspbian.</p>
<pre><code class="language-bash">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

<h3>External links for further information</h3>
<li><a href="https://www.raspberrypi.org/downloads/raspbian/" target="_blank">
<li><a href="https://github.com/raspberrypi/tools" target="_blank">