Cross compilation using Boost library

Dear whom it may concern,

I’m using Ubuntu 18.04 as host, and DRIVE 10.0 for target Xavier.
I used the boost libray in my code by invoking.

#include <boost/math/special_functions/round.hpp>

The boost library is by default at location of /usr/lib/x86_64-linux-gnu/libboost_math_[c99f/c99l/tr1l/tr1f].so. And the .hpp file is at /usr/include/boost/math/special_functions/round.hpp.

Then when I compile it on the host using following cmake commands, it works well.

zzz@PC:~/dwTests/build$
cmake -DCMAKE_BUILD_TYPE=Release ..

But when I try to cross compile it for my target Xavier, the cmake cannot find the correct boost package.
I’m using the toolchain as follow:

zzz@PC:~/dwTests/build$
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-V5L.cmake \
-DVIBRANTE_PDK:STRING=/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux \
..

And the error is:

/home/zzz/dwTests/src/hello_world/hello_world.cpp:39:10: fatal error: boost/math/special_functions/round.hpp: No such file or directory
 #include <boost/math/special_functions/round.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I tried to setup the include and library directories of boost in the hello_world/CMakeLists.txt. But it didn’t help at all.

set(BOOST_INCLUDEDIR "/usr/include")
set(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu")
include_directories(${BOOST_INCLUDEDIR})
link_directories(${BOOST_LIBRARYDIR})

Also, I tried to use find_package:

find_package(Boost COMPONENTS math REQUIRED)

But the result is:

CMake Error at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1947 (message):
  Unable to find the requested Boost libraries.
  Boost version: 1.65.1
  Boost include path: /usr/include
  Could not find the following Boost libraries:
          boost_math

So I would like to ask your help for this situation.

Dear hanyang.zhuang,
I could find boost libs files for target at ~/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/lib/aarch64-linux-gnu/ . COuld you check with this lib path?

Hi SivaRamaKrishna,

Thanks to your feedback. I was not doing it correctly previously. Your information is correct.

Moreover, I have engaged another issue. What I am doing is to cross-compile ROS and want to use ROS and Driveworks together for network communication and perception algorithm development.

Currently, I have cross-compiled ROS bare bone on the Xavier. I can x-compile a simple ROS node, scp it to the target, and run it on the target. Everything goes well with the ROS is running alone. On the other hand, I have also done x-compiling of Driveworks sample “hello-world” and run it on the target.
So what I am doing now is try to use Driveworks and ROS together, but during the x-compiling, there are some issues. I’m just a beginner in using cmake so perhaps many of the questions are related with that. Following is my situation:
ail_ros_node is the node I created, and all the others are ROS sources.

zhy@zhy-HP-ZBook-15-G5:~/ros-bare-bone-src$ tree -L 2 .
.
├── melodic-ros_comm-wet.rosinstall
└── src
    ├── ail_ros_node
    ├── catkin
    ├── class_loader
    ├── cmake_modules
    ├── gencpp
    ├── geneus
    ├── genlisp
    ├── genmsg
    ├── gennodejs
    ├── genpy
    ├── message_generation
    ├── message_runtime
    ├── pluginlib
    ├── ros
    ├── ros_comm
    ├── ros_comm_msgs
    ├── rosconsole
    ├── roscpp_core
    ├── ros_environment
    ├── roslisp
    ├── rospack
    └── std_msgs
zhy@zhy-HP-ZBook-15-G5:~/ros-bare-bone-src/src/ail_ros_node$ tree -L 1
.
├── 3rdparty
├── cmake
├── CMakeLists.txt
├── framework
├── include
├── package.xml
└── src

According to the instructions, I have developed a cross compilation toolchain.

set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION 1)
set(VIBRANTE_BUILD ON)       #flags for the CMakeList.txt
set(CMAKE_SYSTEM_PROCESSOR aarch64)
# need that one here, because this is a toolchain file and hence executed before
# default cmake settings are set
set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so")

set(VIBRANTE_PDK "/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux")
set(MYSYSROOT "/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a")


# check that Vibrante PDK must be set
if(NOT DEFINED VIBRANTE_PDK)
    if(DEFINED ENV{VIBRANTE_PDK})
        message(STATUS "VIBRANTE_PDK = ENV : $ENV{VIBRANTE_PDK}")
        set(VIBRANTE_PDK $ENV{VIBRANTE_PDK} CACHE STRING "Path to the vibrante-XXX-linux path for cross-compilation" FORCE)
    endif()
else()
     message(STATUS "VIBRANTE_PDK = ${VIBRANTE_PDK}")
endif()

if(DEFINED VIBRANTE_PDK)
  if(NOT IS_ABSOLUTE ${VIBRANTE_PDK})
      get_filename_component(VIBRANTE_PDK "${SDK_BINARY_DIR}/${VIBRANTE_PDK}" ABSOLUTE)
  endif()
endif()

set(ARCH "aarch64")
set(VIBRANTE TRUE)
set(VIBRANTE_V5L TRUE)
add_definitions(-DVIBRANTE -DVIBRANTE_V5L)

# determine target device and pdk branch
if(NOT DEFINED VIBRANTE_PDK_DEVICE AND VIBRANTE_PDK)
    if(${VIBRANTE_PDK} MATCHES "(vibrante|drive)-(t.+)-linux$")
        set(VIBRANTE_PDK_DEVICE ${CMAKE_MATCH_2} CACHE STRING "Cross-compilation target device")
        message(STATUS "VIBRANTE_PDK_DEVICE = ${VIBRANTE_PDK_DEVICE}")
    else()
        message(FATAL_ERROR "Can't determine target device for PDK: ${VIBRANTE_PDK}")
    endif()
endif()

if(NOT DEFINED VIBRANTE_PDK_BRANCH AND VIBRANTE_PDK)
    if(EXISTS "${VIBRANTE_PDK}/lib-target/version-nv-pdk.txt")
        set(VIBRANTE_PDK_FILE "${VIBRANTE_PDK}/lib-target/version-nv-pdk.txt")
    elseif(EXISTS "${VIBRANTE_PDK}/lib-target/version-nv-sdk.txt")
        set(VIBRANTE_PDK_FILE "${VIBRANTE_PDK}/lib-target/version-nv-sdk.txt")
    endif()

    if(VIBRANTE_PDK_FILE)
       file(READ ${VIBRANTE_PDK_FILE} version-nv-pdk)
       if(${version-nv-pdk} MATCHES "^(.+)-[0123456789]+")
           set(VIBRANTE_PDK_BRANCH ${CMAKE_MATCH_1} CACHE STRING "Cross-compilation PDK branch name")
           message(STATUS "VIBRANTE_PDK_BRANCH = ${VIBRANTE_PDK_BRANCH}")
       else()
           message(FATAL_ERROR "Can't determine PDK branch for PDK ${VIBRANTE_PDK}")
       endif()
    else()
       message(FATAL_ERROR "Can't open ${VIBRANTE_PDK}/lib-target/version-nv-(pdk/sdk).txt for PDK branch detection")
    endif()
endif()

if(DEFINED VIBRANTE_PDK_BRANCH)
  string(REPLACE "." ";" PDK_VERSION_LIST ${VIBRANTE_PDK_BRANCH})

  # Some PDK's have less than three version numbers. Pad the list so we always
  # have at least three numbers, allowing pre-existing logic depending on major,
  # minor, patch versioning to work without modifications
  list(LENGTH PDK_VERSION_LIST _PDK_VERSION_LIST_LENGTH)
  while(_PDK_VERSION_LIST_LENGTH LESS 3)
    list(APPEND PDK_VERSION_LIST 0)
    math(EXPR _PDK_VERSION_LIST_LENGTH "${_PDK_VERSION_LIST_LENGTH} + 1")
  endwhile()

  set(VIBRANTE_PDK_PATCH 0)
  set(VIBRANTE_PDK_BUILD 0)

  list(LENGTH PDK_VERSION_LIST PDK_VERSION_LIST_LENGTH)

  list(GET PDK_VERSION_LIST 0 VIBRANTE_PDK_MAJOR)
  list(GET PDK_VERSION_LIST 1 VIBRANTE_PDK_MINOR)
  if(PDK_VERSION_LIST_LENGTH GREATER 2)
    list(GET PDK_VERSION_LIST 2 VIBRANTE_PDK_PATCH)
  endif()

  if(PDK_VERSION_LIST_LENGTH GREATER 3)
    list(GET PDK_VERSION_LIST 3 VIBRANTE_PDK_BUILD)
  endif()

  set(VIBRANTE_PDK_VERSION ${VIBRANTE_PDK_MAJOR}.${VIBRANTE_PDK_MINOR}.${VIBRANTE_PDK_PATCH}.${VIBRANTE_PDK_BUILD})

  add_definitions(-DVIBRANTE_PDK_VERSION=\"${VIBRANTE_PDK_VERSION}\") # requires escaping so it is treated as a string
                                                                      # and not an invalid floating point with too many decimal points
  add_definitions(-DVIBRANTE_PDK_MAJOR=${VIBRANTE_PDK_MAJOR})
  add_definitions(-DVIBRANTE_PDK_MINOR=${VIBRANTE_PDK_MINOR})
  add_definitions(-DVIBRANTE_PDK_PATCH=${VIBRANTE_PDK_PATCH})
  add_definitions(-DVIBRANTE_PDK_BUILD=${VIBRANTE_PDK_BUILD})

  math(EXPR VIBRANTE_PDK_DECIMAL "${VIBRANTE_PDK_MAJOR} * 1000000 + \
                                  ${VIBRANTE_PDK_MINOR} * 10000 + \
                                  ${VIBRANTE_PDK_PATCH} * 100 + \
                                  ${VIBRANTE_PDK_BUILD}")
  add_definitions(-DVIBRANTE_PDK_DECIMAL=${VIBRANTE_PDK_DECIMAL})

  message(STATUS "Vibrante version ${VIBRANTE_PDK_VERSION}")
endif()

# If VIBRANTE_C_COMPILER and VIBRANTE_CXX_COMPILER are defined, they will be used.
# if not the PDK-internal compiler will be used (default behavior)
if(DEFINED VIBRANTE_C_COMPILER AND DEFINED VIBRANTE_CXX_COMPILER)
  # Determine C and CXX compiler versions
  exec_program(${VIBRANTE_C_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE C_COMPILER_VERSION RETURN_VALUE C_COMPILER_VERSION_ERROR)
  exec_program(${VIBRANTE_CXX_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE CXX_COMPILER_VERSION RETURN_VALUE CXX_COMPILER_VERSION_ERROR)

  # Make sure C and CXX compiler versions match
  if(${C_COMPILER_VERSION_ERROR})
    message(FATAL_ERROR "Received error ${C_COMPILER_VERSION_ERROR} when determining compiler version for ${VIBRANTE_C_COMPILER}")
  elseif(${CXX_COMPILER_VERSION_ERROR})
    message(FATAL_ERROR
    "Received error ${CXX_COMPILER_VERSION_ERROR} when determining compiler version for ${VIBRANTE_CXX_COMPILER}")
  elseif(NOT ${C_COMPILER_VERSION} VERSION_EQUAL ${CXX_COMPILER_VERSION})
    message(FATAL_ERROR
    "C and CXX compiler versions must match.\n"
    "Found C Compiler Version = ${C_COMPILER_VERSION}\n"
    "Found CXX Compiler Version = ${CXX_COMPILER_VERSION}\n")
  endif()
  set(CMAKE_C_COMPILER ${VIBRANTE_C_COMPILER})
  set(CMAKE_CXX_COMPILER ${VIBRANTE_CXX_COMPILER})
  set(GCC_COMPILER_VERSION "${C_COMPILER_VERSION}" CACHE STRING "GCC Compiler version")
else()
  if(VIBRANTE_PDK_DECIMAL LESS 5010300)
    set(TOOLCHAIN "${VIBRANTE_PDK}/../toolchains/tegra-4.9-nv")
    set(CMAKE_CXX_COMPILER "${TOOLCHAIN}/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-g++")
    set(CMAKE_C_COMPILER "${TOOLCHAIN}/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gcc")
    set(GCC_COMPILER_VERSION "4.9" CACHE STRING "GCC Compiler version")
  else()
    set(TOOLCHAIN "${VIBRANTE_PDK}/../toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu")
    set(CMAKE_CXX_COMPILER "${TOOLCHAIN}/bin/aarch64-linux-gnu-g++")
    set(CMAKE_C_COMPILER "${TOOLCHAIN}/bin/aarch64-linux-gnu-gcc")
    set(GCC_COMPILER_VERSION "7.3.1" CACHE STRING "GCC Compiler version")
  endif()
endif()


# Specify the cross compiler
# set(TOOLCHAIN "/home/sbyun/Downloads/gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu")
set(TOOLCHAIN "/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu")
set(CMAKE_CXX_COMPILER "${TOOLCHAIN}/bin/aarch64-linux-gnu-g++")
set(CMAKE_C_COMPILER "${TOOLCHAIN}/bin/aarch64-linux-gnu-gcc")

# Targetfs path

set(LD_PATH "${MYSYSROOT}/usr/lib/aarch64-linux-gnu")
set(LD_PATH_EXTRA_1 "${MYSYSROOT}/lib/aarch64-linux-gnu")

set(ROSCONSOLE_BACKEND "print")

# setup compiler for cross-compilation
set(CMAKE_CXX_FLAGS           "-fPIC"               CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS             "-fPIC"               CACHE STRING "c flags")
set(CMAKE_SHARED_LINKER_FLAGS ""                    CACHE STRING "shared linker flags")
set(CMAKE_MODULE_LINKER_FLAGS ""                    CACHE STRING "module linker flags")
set(CMAKE_EXE_LINKER_FLAGS    ""                    CACHE STRING "executable linker flags")


# Where is the target environment
set(CMAKE_FIND_ROOT_PATH ${MYSYSROOT})

# Please, be carefull looks like "-Wl,-unresolved-symbols=ignore-in-shared-libs" can lead to silent "ld" problems
set(CMAKE_SHARED_LINKER_FLAGS   "--sysroot=${CMAKE_FIND_ROOT_PATH} -L${LD_PATH} -L${LD_PATH_EXTRA_1} -Wl,-rpath,${LD_PATH} -Wl,-rpath,${LD_PATH_EXTRA_1} ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS   "--sysroot=${CMAKE_FIND_ROOT_PATH} -L${LD_PATH} -L${LD_PATH_EXTRA_1} -Wl,-rpath,${LD_PATH} -Wl,-rpath,${LD_PATH_EXTRA_1} ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS      "--sysroot=${CMAKE_FIND_ROOT_PATH} -L${LD_PATH} -L${LD_PATH_EXTRA_1} -Wl,-rpath,${LD_PATH} -Wl,-rpath,${LD_PATH_EXTRA_1} ${CMAKE_EXE_LINKER_FLAGS}")


set(CMAKE_C_FLAGS "-fPIC --sysroot=${CMAKE_FIND_ROOT_PATH}" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS "-fPIC --sysroot=${CMAKE_FIND_ROOT_PATH}" CACHE INTERNAL "" FORCE)

# Search for programs only in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search for libraries and headers only in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# set system default include dir
include_directories(BEFORE SYSTEM ${MYSYSROOT}/../include)

Then, I used catkin_make to compile the whole ros bare bone. In the ail_ros_node_src, it is a similar file tree to the DW sample. I can host compile this ros package using catkin_make, so the files shall be correct. The CMakeLists.txt in the ail_ros_node is like this:

cmake_minimum_required(VERSION 2.8.3)
project(ail_ros_node)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
)


catkin_package(

)

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)


set(CMAKE_DEBUG on)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(SamplesSetBuildType) # Set the build type before project is created
set(SDK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(SDK_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CUDA_TOOLKIT_ROOT_DIR ${MYSYSROOT}/usr/local/cuda-10.2)
set(CUDA_INCLUDE_DIRS ${MYSYSROOT}/usr/local/cuda-10.2/targets/aarch64-linux/include)
set(CUDA_CUDART_LIBRARY ${MYSYSROOT}/usr/local/cuda-10.2/targets/aarch64-linux/lib)
set(CUDA_TOOLKIT_ROOT_DIR ${MYSYSROOT}/usr/local/cuda-10.2/bin)
message(${CUDA_INCLUDE_DIRS})
message(${CUDA_CUDART_LIBRARY})
message(${CUDA_NVCC_EXECUTABLE})


include(ArchConfiguration)
include(CommonConfiguration)
include(ResourcesConfiguration)
include(SamplesConfiguration)
include(Samples3rdparty)
include(SamplesInstallConfiguration)
include(ExpandDependencyTree)
include(IncludeTargetDirectories)
include(UploadVibrante)
set(SDK_BINARY_DIR ${CMAKE_BINARY_DIR})

find_package(Driveworks REQUIRED)
include_directories(${Driveworks_INCLUDE_DIR})

list(APPEND Driveworks_LIBRARIES
    ${CUDA_LIBRARIES}
    ${CUDA_cublas_LIBRARY}
)

set(LIBRARIES 
	${Driveworks_LIBRARIES}
	${catkin_LIBRARIES}
)

message(${VIBRANTE})
message(${CMAKE_CROSSCOMPILING})

if(LINUX)
    list(APPEND Driveworks_LIBRARIES)
elseif(VIBRANTE)
    list(APPEND Driveworks_LIBRARIES ${vibrante_LIBRARIES} ${vibrante_Xlibs_LIBRARIES} nvmedia ${EGL_LIBRARIES})
endif()

if(CMAKE_CROSSCOMPILING)
  set(DRIVEWORKS_DATAPATH "../data")
else()
  set(DRIVEWORKS_DATAPATH "${CMAKE_CURRENT_LIST_DIR}/../data")
endif()

include_directories(${SDK_BINARY_DIR}/configured/samples)
configure_file(framework/DataPath.hpp.in
              ${SDK_BINARY_DIR}/configured/samples/framework/DataPath.hpp)

add_subdirectory(framework)

add_cuda_dependencies_target(update_cuda_deps ON)
set_property(TARGET update_cuda_deps PROPERTY FOLDER "Support")

add_executable(${PROJECT_NAME} src/test_ros_node.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBRARIES})

Then when I use catkin_make to compile the ros nodes, errors raise up:

==> Processing catkin package: 'ail_ros_node'
==> Building with env: '/home/zhy/install_isolated/env.sh'
==> cmake /home/zhy/ros-bare-bone-src/src/ail_ros_node -DCATKIN_DEVEL_PREFIX=/home/zhy/devel_isolated/ail_ros_node -DCMAKE_INSTALL_PREFIX=/home/zhy/install_isolated -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/home/zhy/ros-xavier-toolchain.cmake -DCATKIN_ENABLE_TESTING=false -G Unix Makefiles in '/home/zhy/build_isolated/ail_ros_node'
-- VIBRANTE_PDK = /home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux
-- Vibrante version 5.1.6.1
-- Using CATKIN_DEVEL_PREFIX: /home/zhy/devel_isolated/ail_ros_node
-- Using CMAKE_PREFIX_PATH: /home/zhy/install_isolated
-- This workspace overlays: /home/zhy/install_isolated
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: false
-- catkin 0.7.20
-- BUILD_SHARED_LIBS is on
/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/local/cuda-10.2/targets/aarch64-linux/include
/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/local/cuda-10.2/targets/aarch64-linux/lib
/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/local/cuda-10.2/bin
-- Cross Compiling for Vibrante
-- Default - Building with TRT version 5.1.4.2 and cudnn version 7.5.1.14
CMake Error at cmake/FindCUDA.cmake:678 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.
Call Stack (most recent call first):
  cmake/SamplesConfiguration.cmake:6 (find_package)
  CMakeLists.txt:223 (include)


CMake Error at cmake/FindCUDA.cmake:679 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.
Call Stack (most recent call first):
  cmake/SamplesConfiguration.cmake:6 (find_package)
  CMakeLists.txt:223 (include)


-- Found CUDA: /home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/local/cuda-10.2 (found version ".") 
-- Building GLFW for X11 (shared)
-- Looking for XOpenDisplay in /home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/lib/aarch64-linux-gnu/libX11.so;/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/lib/aarch64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/lib/aarch64-linux-gnu/libX11.so;/home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/lib/aarch64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /home/zhy/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_a/usr/lib/aarch64-linux-gnu/libX11.so
-- Building GLFW for Wayland (shared)
CMake Warning (dev) at /usr/share/ECM/modules/ECMFindModuleHelpers.cmake:133 (message):
  Your project should require at least CMake 2.8.12 to use FindWayland.cmake
Call Stack (most recent call first):
  /usr/share/ECM/find-modules/FindWayland.cmake:80 (ecm_find_package_version_check)
  3rdparty/src/glfw/CMakeLists.txt:47 (find_package)
  3rdparty/src/glfw/CMakeLists.txt:97 (glfw_build_for_winsys)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find Wayland_Client (missing: Wayland_Client_INCLUDE_DIR) (found version "1.16.0")
-- Could NOT find Wayland_Server (missing: Wayland_Server_INCLUDE_DIR) (found version "1.16.0")
-- Could NOT find Wayland_Cursor (missing: Wayland_Cursor_INCLUDE_DIR) (found version "1.16.0")
-- Could NOT find Wayland_Egl (missing: Wayland_Egl_INCLUDE_DIR Wayland_Client_FOUND) (found version "18.1.0")
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Wayland (missing: Wayland_LIBRARIES) (found version
  "1.16.0")
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/ECM/find-modules/FindWayland.cmake:129 (find_package_handle_standard_args)
  3rdparty/src/glfw/CMakeLists.txt:47 (find_package)
  3rdparty/src/glfw/CMakeLists.txt:97 (glfw_build_for_winsys)


-- Configuring incomplete, errors occurred!
See also "/home/zhy/build_isolated/ail_ros_node/CMakeFiles/CMakeOutput.log".
See also "/home/zhy/build_isolated/ail_ros_node/CMakeFiles/CMakeError.log".
<== Failed to process package 'ail_ros_node': 
  Command '['/home/zhy/install_isolated/env.sh', 'cmake', '/home/zhy/ros-bare-bone-src/src/ail_ros_node', '-DCATKIN_DEVEL_PREFIX=/home/zhy/devel_isolated/ail_ros_node', '-DCMAKE_INSTALL_PREFIX=/home/zhy/install_isolated', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_TOOLCHAIN_FILE=/home/zhy/ros-xavier-toolchain.cmake', '-DCATKIN_ENABLE_TESTING=false', '-G', 'Unix Makefiles']' returned non-zero exit status 1

Reproduce this error by running:
==> cd /home/zhy/build_isolated/ail_ros_node && /home/zhy/install_isolated/env.sh cmake /home/zhy/ros-bare-bone-src/src/ail_ros_node -DCATKIN_DEVEL_PREFIX=/home/zhy/devel_isolated/ail_ros_node -DCMAKE_INSTALL_PREFIX=/home/zhy/install_isolated -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/home/zhy/ros-xavier-toolchain.cmake -DCATKIN_ENABLE_TESTING=false -G 'Unix Makefiles'

Command failed, exiting.
zhy@zhy-HP-ZBook-15-G5:~$

Can you help with figuring out the reasons? Or can you please make a sample cross-compile toolchain and CMakeLists to combine the simplest ROS and DW usages together? Thanks a lot and I’m looking forward to your feedback.

Hi hanyang.zhuang,

Is this a duplicate topic of https://devtalk.nvidia.com/default/topic/1065380/general/nvros/? Thanks!

Hi VickNV,

Yes, you can merge the two threads together. Thanks

Hi hanyang.zhuang,

first of all: Thanks for sharing your progress at https://devtalk.nvidia.com/default/topic/1070193/cross-compile-target-file-including-ros-and-driveworks/?offset=5.
I followed a very similar path and thus find this very helpful. I also try to cross-compile a combination of ros publisher and DW Hello World sample. I now arrived at the exact same problem that you had in this thread. Do you remember what helped you moving on from here?

– Could NOT find Wayland_Client (missing: Wayland_Client_INCLUDE_DIR) (found version “1.16.0”)
– Could NOT find Wayland_Server (missing: Wayland_Server_INCLUDE_DIR) (found version “1.16.0”)
– Could NOT find Wayland_Cursor (missing: Wayland_Cursor_INCLUDE_DIR) (found version “1.16.0”)
– Could NOT find Wayland_Egl (missing: Wayland_Egl_INCLUDE_DIR Wayland_Client_FOUND) (found version “18.1.0”)

Thanks

Hi seyed.eghbal.ghobadi,

I remember I do have met those problems. But the actual solution is not very clear in my head.

You can try following approach:

  1. One thing you can do is try to install wayland on the targetfs_a folder of your host machine, which I remeber is, or similar way:
    sudo apt install libwayland-dev
    

    You need to use the command sudo LC_ALL=C chroot and then install it for the VIBRANTE_PDK/targetfs_a folder, and on the target Xavier to align the libraries. Just like what you did for apt installation of ROS.

  2. Another is when you look at the cmake output on the terminal, did you see EGL Found? or EGL Not Found? If EGL not found, then you can look at the end of the thread you referenced. "If Could NOT find EGL (missing: EGL_LIBRARY) is shown during compiling, then you need to specify the cmake/FindEGL.cmake find_library command as find_library(EGL_LIBRARY EGL ${VIBRANTE_PDK}/lib-target). I'm not clear with the reason why the cross compiler cannot properly find EGL_LIBRAY."

Thank you, installing the missing libraries with sudo LC_ALL=C chroot did the trick for me. I also came across the EGL Not Found error before but I was already able to resolve that using your instructions in the other thread linked above.