mycelial technology

Cross-Compiling Rust for Debian Buster on Raspberry Pi 3B+

18 May, 2020

Install target platform:

rustup target add aarch64-unknown-linux-gnu

Install toolchain:

rustup toolchain install nightly-aarch64-unknown-linux-gnu

Install aarch64-linux-gnu-gcc:

sudo apt-get install gcc-aarch64-linux-gnu

Configure the linker*:

export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc

Compile release build:

cargo build --release --target=aarch64-unknown-linux-gnu

* Another approach is to create `cargo-config` in the root directory of the repo and add the following:

linker = "aarch64-linux-gnu-gcc"