====== 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 ===== * Unordered List ItemInstall aarch64 compiler * ''sudo apt-get install g++-aarch64-linux-gnu'' * Mount target filesystem * ''sudo mkdir /mnt/rpi'' * ''sudo sshfs -o allow_other,default_permissions [target_username]@[target_ip]:/ /mnt/rpi'' * Create ''toolchain.cmake'' file, see section below. * Configure cmake to use toolchain file * ''cmake -DCMAKE_TOOLCHAIN_FILE=..[toolchain_file] [project_location]'' * ''make -j[threads_to_use]'' ==== 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)