[ROS2]error while loading shared libraries: libxsensdeviceapi.so.4: cannot open shared object file: No such file or directory
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.