Deploying thirdparty libraries with ROS2 node

asked 2022-03-03 08:59:41 -0600

NotARobot gravatar image

I'm trying to deploy the LDSO vision based SLAM for my ROS2 project. I have a workspace structure looking like this:

workspace
|-src
|--ldso
|---thirdparty
|----g2o
|-----lib
|------libg2o.so
|---...
|---CMakeLists.txt
|---package.xml

Furthermore I'm working with CLion IDE. When I build and run the LDSO node I've created within CLion, the node starts without troubles. However, when I build and deploy inside my workspace via colcon and run my node, the shared object library libg2o.so is not to be found by my node, giving the error error while loading shared libraries: libg2o.so: cannot open shared object file: No such file or directory. Since shared objects are linked within runtime this makes sense, so I've added

install(FILES ${PROJECT_SOURCE_DIR}/thirdparty/g2o/lib/libg2o.so DESTINATION lib/${PROJECT_NAME})

to my CMakeLists.txt and

<exec_depend>libg2o</exec_depend>

to my package.xml. Nevertheless the problem still persists. With a bit of digging I found that the library could possibly be found if installed in /usr/lib/ or /opt/ros/foxy/lib/ or with adding the directory to LD_LIBRARY_PATH. I find neither of these solutions satisfying in order for a simpler, more self contained deployment. Is there a possibility to tell my node where to search for this third-party library (e.g. in the before mentioned path parallel to my node)?

edit retag flag offensive close merge delete