0
$\begingroup$

Hello Im trying to write a client node using ros2 humble hawksbill distribution. For the node Im using a shared library for my depth camera. I have linked the .so file as I would normally do in my CMakelists.txt. The .so file is placed in a folder in my package called /thirdparty. This is how I have linked the .so file in the CMakelists.txt file:

if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
  find_library(libCubeEye NAMES libCubeEye.so HINTS ${PROJECT_SOURCE_DIR}/thirdparty/aarch64/libcubeeye/lib/)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
  if(UNIX)
    find_library(libCubeEye NAMES libCubeEye.so HINTS ${PROJECT_SOURCE_DIR}/thirdparty/x86_64/libcubeeye/lib)
  endif(UNIX)
endif()

if (NOT libCubeEye)
  message(FATAL_ERROR "libCubeEye library not found")
endif()

#ament_export_targets(libCubeEye HAS_LIBRARY_TARGET)

include_directories(
  ${OpenCV_INCLUDE_DIRS}
  thirdparty/${CMAKE_HOST_SYSTEM_PROCESSOR}/libcubeeye/include
  thirdparty/${CMAKE_HOST_SYSTEM_PROCESSOR}/onnxruntime-linux-x64-1.15.1/include
)

It builds without issues but as soon as I run my node, I get the following error:

/home/victor/ros2_ws/install/cpp_inference_client/lib/cpp_inference_client/infernce_client: error while loading shared libraries: libCubeEye.so: cannot open shared object file: No such file or directory [ros2run]: Process exited with failure 127

$\endgroup$

1 Answer 1

1
$\begingroup$

Please try the following

find_library(MYLIB test_lib.so)

add_executable(test main.c)

target_link_libraries(test MYLIB)

https://cmake.org/cmake/help/latest/command/add_library.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.