Cross compilation JETSON XAVIER NX

Hey,
I have been trying to cross-compile from ubuntu18.04 to the jetson xavier NX now for almost 3 weeks.
I’m new to cross compiling so i think i am lacking some knowledge.
i have successfully created a image that can compile everything on the jetson xavier nx itself and have mounted its image file on my host system at the /mnt
as a mount point.

i’m using cmake and the toolchain file i have configured so far is:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)

set(CMAKE_SYSTEM_PROCESSOR aarch64)

macro(find_host_program)
endmacro()

macro(find_host_package)
endmacro()

set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -isysroot /mnt -I /mnt/usr/include”)

set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc-8)
set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g+±8)

set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)

set(CMAKE_SYSROOT /mnt)
set(CMAKE_FIND_ROOT_PATH /mnt/usr/lib/aarch64-linux-gnu/cmake;/mnt/missioncontroller_mark2/ros2;/home/lioredis/dev_env/cross_compile_local/missioncontroller_mark2/ros2/build;/home/lioredis/dev_env/cross_compile_local/missioncontroller_mark2/ros2/install;/home/lioredis/mount_point/usr/lib/aarch64-linux-gnu)
#set(CMAKE_INSTALL_RPATH /mnt/usr/lib/aarch64-linux-gnu)

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

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(PYTHON_SOABI cpython-36m-aarch64-linux-gnu)
set(THREADS_PTHREAD_ARG “0” CACHE STRING “Result from TRY_RUN” FORCE)

some of my packages that i need to compile are successful while others encounter warnings followed by compiler errors which i can’t seem to solve. there seems to be some mismatch between the compiler and include libraries.

CMake Warning at /mnt/opt/ros/eloquent/share/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake:50 (add_executable):
  Cannot generate a safe runtime search path for target pcl_conversions-test
  because files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libboost_system.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libboost_filesystem.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libboost_thread.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libboost_date_time.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libboost_iostreams.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libboost_serialization.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libboost_chrono.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libboost_atomic.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libboost_regex.so.1.65.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libpcl_common.so.1.8] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libpcl_octree.so.1.8] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libpcl_io.so.1.8] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libQt5WebKit.so.5] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libQt5Network.so.5] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libQt5Gui.so.5] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libEGL.so.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libGLESv2.so.2] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libQt5Core.so.5] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu

  Some of these libraries may not be found correctly.
Call Stack (most recent call first):
  /mnt/opt/ros/eloquent/share/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake:37 (_ament_add_gtest_executable)
  /mnt/opt/ros/eloquent/share/ament_cmake_gtest/cmake/ament_add_gtest.cmake:68 (ament_add_gtest_executable)
  CMakeLists.txt:44 (ament_add_gtest)


CMake Warning at /mnt/opt/ros/eloquent/share/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake:50 (add_executable):
  Cannot generate a safe dependent library path for target
  pcl_conversions-test because files in some directories may conflict with
  libraries in implicit directories:

    runtime library [libQt5WebKit.so.5] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libQt5Network.so.5] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libEGL.so.1] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu
    runtime library [libGLESv2.so.2] in /mnt/usr/lib/aarch64-linux-gnu may be hidden by files in:
      /usr/lib/x86_64-linux-gnu

  Some of these libraries may not be found correctly.
Call Stack (most recent call first):
  /mnt/opt/ros/eloquent/share/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake:37 (_ament_add_gtest_executable)
  /mnt/opt/ros/eloquent/share/ament_cmake_gtest/cmake/ament_add_gtest.cmake:68 (ament_add_gtest_executable)
  CMakeLists.txt:44 (ament_add_gtest)


   In file included from /usr/aarch64-linux-gnu/include/wchar.h:30,
                 from /usr/aarch64-linux-gnu/include/c++/8/cwchar:44,
                 from /usr/aarch64-linux-gnu/include/c++/8/bits/postypes.h:40,
                 from /usr/aarch64-linux-gnu/include/c++/8/iosfwd:40,
                 from /usr/aarch64-linux-gnu/include/c++/8/memory:72,
                 from /mnt/opt/ros/eloquent/src/gtest_vendor/include/gtest/gtest.h:56,
                 from /mnt/opt/ros/eloquent/src/gtest_vendor/src/gtest_main.cc:31:
/usr/include/x86_64-linux-gnu/bits/floatn.h:87:9: error: '__float128' does not name a type; did you mean '__cfloat128'?
 typedef __float128 _Float128;
         ^~~~~~~~~~
         __cfloat128
In file included from /usr/aarch64-linux-gnu/include/c++/8/cwchar:44,
                 from /usr/aarch64-linux-gnu/include/c++/8/bits/postypes.h:40,
                 from /usr/aarch64-linux-gnu/include/c++/8/iosfwd:40,
                 from /usr/aarch64-linux-gnu/include/c++/8/memory:72,
                 from /mnt/opt/ros/eloquent/src/gtest_vendor/include/gtest/gtest.h:56,
                 from /mnt/opt/ros/eloquent/src/gtest_vendor/src/gtest_main.cc:31:
/usr/aarch64-linux-gnu/include/wchar.h:406:8: error: '_Float128' does not name a type; did you mean '_Float32x'?
 extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
        ^~~~~~~~~
        _Float32x
/usr/aarch64-linux-gnu/include/wchar.h:523:8: error: '_Float128' does not name a type; did you mean '_Float32x'?
 extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
        ^~~~~~~~~
        _Float32x
In file included from /usr/aarch64-linux-gnu/include/wchar.h:30,
                 from /usr/aarch64-linux-gnu/include/c++/8/cwchar:44,
                 from /usr/aarch64-linux-gnu/include/c++/8/bits/postypes.h:40,
                 from /usr/aarch64-linux-gnu/include/c++/8/iosfwd:40,
                 from /usr/aarch64-linux-gnu/include/c++/8/memory:72,
                 from /mnt/opt/ros/eloquent/src/gtest_vendor/include/gtest/gtest.h:56,
                 from /mnt/opt/ros/eloquent/src/gtest_vendor/src/gtest-all.cc:38:
/usr/include/x86_64-linux-gnu/bits/floatn.h:87:9: error: '__float128' does not name a type; did you mean '__cfloat128'?
 typedef __float128 _Float128;
         ^~~~~~~~~~
         __cfloat128
In file included from /usr/aarch64-linux-gnu/include/c++/8/cwchar:44,
                 from /usr/aarch64-linux-gnu/include/c++/8/bits/postypes.h:40,
                 from /usr/aarch64-linux-gnu/include/c++/8/iosfwd:40,
                 from /usr/aarch64-linux-gnu/include/c++/8/memory:72,
                 from /mnt/opt/ros/eloquent/src/gtest_vendor/include/gtest/gtest.h:56,
                 from /mnt/opt/ros/eloquent/src/gtest_vendor/src/gtest-all.cc:38:
/usr/aarch64-linux-gnu/include/wchar.h:406:8: error: '_Float128' does not name a type; did you mean '_Float32x'?
 extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
        ^~~~~~~~~
        _Float32x
/usr/aarch64-linux-gnu/include/wchar.h:523:8: error: '_Float128' does not name a type; did you mean '_Float32x'?
 extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
        ^~~~~~~~~
        _Float32x

i have tried using gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu as a cross compiler but cmake cant seem to find some of my libraries even before getting to compilation. as you can see in the toolchain file i tried changing cxx compiler flags to look and find header files on the /mnt point but it didnt really work.
of course there are more compiler errors but they seem to derive from this first one. perhaps someone can explain what exactly i’m doing wrong?

regards, Lior.

Not clean for it. Do you want to compile x86 binary from Xavier NX?

i’m trying to compile binaries on my x86 host to run on my Xavier NX

Why just build it on Xavier?

4 hours to compile