0

Hi all I'm trying to crosscompile a ros2 package from an Ubuntu Jammy x86-64 host to an arm64v8 one. The build system is a wrapper on to cmake (full example at https://github.com/peppedxAlto/simplepackage).

I've created a sysroot, installed the aarch64-linux-gnu-g++ compiler and created a cmake toolchain file

#
# CMake Toolchain file for crosscompiling on ARM.
#
# Target operating system name.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_CROSSCOMPILING TRUE)

if("$ENV{SYSROOT}" STREQUAL "" )
  message(FATAL_ERROR "SYSROOT environment variables not defined !!!!")
endif()

# Name of C compiler.
set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++")

# Where to look for the target environment. (More paths can be added here)
set(CMAKE_SYSROOT $ENV{SYSROOT})
set(CMAKE_FIND_ROOT_PATH $ENV{SYSROOT} )
set(CMAKE_INCLUDE_PATH  /usr/include/aarch64-linux-gnu)
set(CMAKE_LIBRARY_PATH  /usr/lib/aarch64-linux-gnu)
set(CMAKE_PROGRAM_PATH  /usr/bin/aarch64-linux-gnu)

# Adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search headers and libraries in the target environment 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)

# This assumes that pthread will be available on the target system
# (this emulates that the return of the TRY_RUN is a return code "0")
set(THREADS_PTHREAD_ARG "0"
  CACHE STRING "Result from TRY_RUN" FORCE)

While this work for simple package as soon as i add a more involeved dependency I get

-- Configuring done
CMake Warning at CMakeLists.txt:15 (add_executable):
  Cannot generate a safe runtime search path for target my_node because files
  in some directories may conflict with libraries in implicit directories:

    runtime library [libpython3.10.so] in /usr/lib/aarch64-linux-gnu may be hidden by files in:
      /home/giellamo/roots/usr/lib/aarch64-linux-gnu

  Some of these libraries may not be found correctly.

followed by

gmake[2]: *** No rule to make target '/usr/lib/aarch64-linux-gnu/libpython3.10.so', needed by 'my_node'.  Stop.
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:137: CMakeFiles/my_node.dir/all] Error 2

in the host /usr/lib/aarch64-linux-gnu there is no libpython3.10, so I don't understand where this whole thing comes out.

Any suggestion?

PeppeDx
  • 133
  • 1
  • 10
  • Not sure about a solution, but this https://stackoverflow.com/q/22536567/1116364 seems related – Daniel Jour Feb 22 '23 at 07:28
  • @DanielJour It seems related but in this case it is a bit different because I don't really have the library in that directory. I don't understand why the error. – PeppeDx Feb 22 '23 at 07:50
  • 1
    So-version path is rarely produced by CMake (or by project) directly. Probably, this path is pointed by some **symlink**. Do you have `libpython3.so` file under `/usr/lib/aarch64-linux-gnu`, or under `/home/giellamo/roots/usr/lib/aarch64-linux-gnu`? In case this file is a symlink, where it points to? – Tsyvarev Feb 22 '23 at 08:10
  • @Tsyvarev Inside ```/home/giellamo/roots/usr/lib/aarch64-linux-gnu ```
    `lrwxrwxrwx 1 giellamo giellamo 20 Feb 22 09:26 libpython3.10.so -> libpython3.10.so.1` It strangely works if i create a symlink in `/usr/lib/aarch64-linux-gnu` `sudo ln -s /home/giellamo/roots/usr/lib/aarch64-linux-gnu/libpython3.10.so`
    – PeppeDx Feb 22 '23 at 08:28

1 Answers1

1

In the end I "fixed" the issue adding a symlink to the libpython3.10.so in the rootfilesystem inside /usr/lib/aarch64-linux-gnu.

It is not a good solution, but it will suffice until a proper one will appear.

PeppeDx
  • 133
  • 1
  • 10