ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

[ROS2]error while loading shared libraries: libxsensdeviceapi.so.4: cannot open shared object file: No such file or directory

asked 2022-02-16 02:48:51 -0500

changcong gravatar image

I'm trying to migrate a ROS1 libraries to ROS2 and have some trouble with setting up the packages.

I can colcon build my package sucessfully, but it display the following error.

error while loading shared libraries: libxsensdeviceapi.so.4: cannot open shared object file: No such file or directory

I use ldd to check my executable package, the package in build file can link to libxsensdeviceapi.so sucessfully, but the package in install file couldn't link to libxsensdeviceapi.so sucessfully.

The following is my file tree in src.

src
└── xsens_mtw_driver-release
       ├── CMakeLists.txt
       ├── include
       │   ├── xsensdeviceapi.h
       │   └── xstypes.h
       ├── lib
       │   ├── libxsensdeviceapi.so -> libxsensdeviceapi.so.4
       │   ├── libxsensdeviceapi.so.4 -> libxsensdeviceapi.so.4.6.0
       │   ├── libxsensdeviceapi.so.4.6.0
       │   ├── libxstypes.so -> libxstypes.so.4
       │   ├── libxstypes.so.4 ->libxstypes.so.4.6.0
       │   └── libxstypes.so.4.6.0
       ├── package.xml
       ├── README.md
       └── src
              ├── conio.c
              ├── conio.h
              ├── console.cpp
              ├── console.h
              ├── findClosestUpdateRate.cpp
              ├── findClosestUpdateRate.h
              ├── mastercallback.cpp
              ├── mastercallback.h
              ├── mtwcallback.cpp
              ├── mtwcallback.h
              ├── mt_w_main.cpp
              ├── myxda.cpp
              └── myxda.h

And the following is my CMakeLists

cmake_minimum_required(VERSION 3.5)
project(xsens_mtw_driver)
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRE
find_package(Boost REQUIRED COMPONENTS system)

include_directories(include)
link_directories(lib)

add_executable(mt_w_manager
  src/mt_w_main.cpp
  src/mastercallback.cpp
  src/mtwcallback.cpp
  src/findClosestUpdateRate.cpp
  src/conio.c
  src/console.cpp
  src/myxda.cpp
)

target_link_libraries(mt_w_manager
  xsensdeviceapi
  xstypes
  pthread
  dl
)

ament_target_dependencies(mt_w_manager rclcpp
std_msgs
sensor_msgs
geometry_msgs)

install(
  DIRECTORY include/
  DESTINATION include
)

install(
  TARGETS mt_w_manager
  DESTINATION lib/${PROJECT_NAME}
)

ament_package()

I suppose it is the problem about my cmakelist's install part, but Idon't know how to fix it. Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2022-02-16 09:28:45 -0500

ChuiV gravatar image

If you're seeing that error when you try to run your node, then I believe you're on the right track. After you build your package, those libraries in your package's lib folder don't get installed. Adding something like

install(
  DIRECTORY lib/
  DESTINATION lib
)

may do the trick.

edit flag offensive delete link more

Comments

Thank you. It works. But I am confused about when I use ldd to check the executable package it dispaly package no found, but the ROS wasn't show the error error while loading shared libraries: libxsensdeviceapi.so.4: cannot open shared object file: No such file or directory again.

changcong gravatar image changcong  ( 2022-02-16 20:30:20 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-02-16 02:48:51 -0500

Seen: 2,609 times

Last updated: Feb 16 '22