Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ubuntu_cross_compiler [2021/01/20 09:04] – created nikolal | ubuntu_cross_compiler [2022/09/19 11:34] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Ubuntu cross compiling with libraries ====== | ====== 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 aarch64 (Raspberry Pi 4B) and using the cmake build tool. It links external libraries by mounting the target filesystem over ssfs | + | 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 |
Line 8: | Line 8: | ||
===== On host ===== | ===== On host ===== | ||
+ | * Unordered List ItemInstall aarch64 compiler | ||
+ | * '' | ||
- | sudo apt-get install g++-aarch64-linux-gnu | + | * Mount target |
- | + | * '' | |
- | Mount filesystem | + | * '' |
- | sudo mkdir /mnt/rpi | + | |
- | sudo sshfs -o allow_other, | + | |
- | + | ||
- | Configure cmake to use toolchain file | + | |
- | cmake -DCMAKE_TOOLCHAIN_FILE=../ | + | |
- | make -j8 | + | |
+ | * Create '' | ||
+ | * Configure cmake to use toolchain file | ||
+ | * '' | ||
+ | * '' | ||
==== Toolchain file ==== | ==== Toolchain file ==== | ||
- | + | | |
- | + | set(CMAKE_SYSTEM_PROCESSOR aarch64) | |
- | + | ||
- | set(CMAKE_SYSTEM_NAME Linux) | + | set(tools /usr/bin) |
- | set(CMAKE_SYSTEM_PROCESSOR aarch64) | + | set(CMAKE_C_COMPILER ${tools}/ |
- | + | set(CMAKE_CXX_COMPILER ${tools}/ | |
- | set(tools /usr/bin) | + | |
- | set(CMAKE_C_COMPILER ${tools}/ | + | set(CMAKE_SYSROOT /mnt/rpi) |
- | set(CMAKE_CXX_COMPILER ${tools}/ | + | |
- | + | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | |
- | set(CMAKE_SYSROOT /mnt/rpi) | + | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
- | + | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | |
- | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | + | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) |
- | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | + | |
- | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | + | |
- | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | + | |