ubuntu_cross_compiler

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ubuntu_cross_compiler [2021/01/20 09:04] – created nikolalubuntu_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 Server 20.04 aarch64 (Raspberry Pi 4B) and using the cmake build tool. It links external libraries by mounting the target filesystem over ''sshfs''.
  
  
Line 8: Line 8:
  
 ===== On host ===== ===== On host =====
 +  * Unordered List ItemInstall aarch64 compiler
 +    * ''sudo apt-get install g++-aarch64-linux-gnu''
  
-sudo apt-get install g++-aarch64-linux-gnu +  * Mount target filesystem 
- +    * ''sudo mkdir /mnt/rpi'' 
-Mount filesystem of rpi +    * ''sudo sshfs -o allow_other,default_permissions [target_username]@[target_ip]:/ /mnt/rpi''
-sudo mkdir /mnt/rpi +
-sudo sshfs -o allow_other,default_permissions ubuntu@192.168.2.171:/ /mnt/rpi +
- +
-Configure cmake to use toolchain file +
-cmake -DCMAKE_TOOLCHAIN_FILE=../dune/toolchain.cmake ../dune +
-make -j8 +
  
 +  * 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 ==== ==== Toolchain file ====
- +  set(CMAKE_SYSTEM_NAME Linux) 
- +  set(CMAKE_SYSTEM_PROCESSOR aarch64) 
- +   
-set(CMAKE_SYSTEM_NAME Linux) +  set(tools /usr/bin) 
-set(CMAKE_SYSTEM_PROCESSOR aarch64) +  set(CMAKE_C_COMPILER ${tools}/aarch64-linux-gnu-gcc-9) 
- +  set(CMAKE_CXX_COMPILER ${tools}/aarch64-linux-gnu-g++-9) 
-set(tools /usr/bin) +   
-set(CMAKE_C_COMPILER ${tools}/aarch64-linux-gnu-gcc-9) +  set(CMAKE_SYSROOT /mnt/rpi) 
-set(CMAKE_CXX_COMPILER ${tools}/aarch64-linux-gnu-g++-9) +   
- +  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)+
  
  • ubuntu_cross_compiler.1611129896.txt.gz
  • Last modified: 2022/09/19 11:33
  • (external edit)