Table of Contents

Ubuntu cross compiling with libraries

This guide describes how to cross compile for aarch64 targets with linking to external libraries from a Ubuntu host. The cross compilation is tested on a x86_64 host running Ubuntu 20.04, a target running Ubuntu Server 20.04 aarch64 (Raspberry Pi 4B) and using the cmake build tool. It links external libraries by mounting the target filesystem over sshfs.

On target

Install external libraries (OMPL: lib-eigen3-dev, boost libraries)

On host

Toolchain file

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(tools /usr/bin)
set(CMAKE_C_COMPILER ${tools}/aarch64-linux-gnu-gcc-9)
set(CMAKE_CXX_COMPILER ${tools}/aarch64-linux-gnu-g++-9)

set(CMAKE_SYSROOT /mnt/rpi)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)