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
.
Install external libraries (OMPL: lib-eigen3-dev, boost libraries)
sudo apt-get install g++-aarch64-linux-gnu
sudo mkdir /mnt/rpi
sudo sshfs -o allow_other,default_permissions [target_username]@[target_ip]:/ /mnt/rpi
toolchain.cmake
file, see section below.cmake -DCMAKE_TOOLCHAIN_FILE=..[toolchain_file] [project_location]
make -j[threads_to_use]
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)