Skip to content

Instantly share code, notes, and snippets.

@gpollo
Last active September 2, 2021 02:55
Show Gist options
  • Save gpollo/5364e4d1eb3362fdd56a0a574fec6418 to your computer and use it in GitHub Desktop.
Save gpollo/5364e4d1eb3362fdd56a0a574fec6418 to your computer and use it in GitHub Desktop.
Cross-compiling applications for Archlinux ARM

Archlinux ARM Cross-Compiling

This document assumes that the host system is running Archlinux.

Host Requirements

On your machine, you need binfmt and qemu static for the target architecture. You can install these packages:

  • binfmt-qemu-static-all-arch
  • qemu-user-static-bin

System Root

You need to download your system root from the official Archlinux ARM website. For example:

# mkdir sysroot
# wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz
# bsdtar -xpf ArchLinuxARM-rpi-aarch64-latest.tar.gz
# rm ArchLinuxARM-rpi-aarch64-latest.tar.gz

Installing Packages

Before changing root, I've found that commenting CheckSpace in sysroot/etc/pacman.conf works better. Assuming binfmt is configured, you can change root and update your systems with the following command:

(host)   # arch-chroot sysroot/ /bin/bash
(chroot) # pacman-key --init
(chroot) # pacman-key --populate archlinuxarm
(chroot) # pacman-key -Syu --noconfirm
(chroot) # pacman-key -S --noconfirm base-devel <packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment