RoboStack / robostack.github.io

180 stars 20 forks source link

cannot find libraries in colcon workspace #36

Closed christianrauch closed 10 months ago

christianrauch commented 10 months ago

I am trying to build a colcon workspace with the sourced/activated robostack environment. I am using a simple workspace with the image_tools package from the demos repo (https://github.com/ros2/demos/tree/rolling/image_tools). For reference, this is the package source on the current humble branch: image_tools.zip

After activating the environment via micromamba activate ros_env, I can build the workspace as usual via colcon build. I get some warnings but the build finishes successfully. After sourcing the workspace via . install/setup.bash, I can also tab-complete the built packages, i.e. ros2 run image_tools [tab tab] will show me the nodes cam2image and showimage.

However, when I try to run any of the nodes, I get:

$ ros2 run image_tools showimage
[...]/install/image_tools/lib/image_tools/showimage: error while loading shared libraries: librclcpp.so: cannot open shared object file: No such file or directory
[ros2run]: Process exited with failure 127

The library librclcpp.so is inside the environment at micromamba/envs/robostackenv/pkgs/ros-humble-rclcpp-16.0.3-py310h7c61026_3/lib/librclcpp.so but it is not discoverable since LD_LIBRARY_PATH is only pointing to install/image_tools/lib.

How am I supposed to use colcon inside the robostack environment?

traversaro commented 10 months ago

Are you using the compilers provided by conda-forge to compile the code? Can you report the content of your environment (i.e. micromamba list)? In theory you should not need to set LD_LIBRARY_PATH to ensure that the loader can find librclcpp.so. However, the location of the library you report is strange, if you environment is ros_env you should be able to find the library at micromamba/envs/ros_env/lib/librclcpp.so.

christianrauch commented 10 months ago

Are you using the compilers provided by conda-forge to compile the code?

I think no. which g++ points to /usr/bin/g++. But you have a point there. I installed micromamba install compilers cmake pkg-config make ninja colcon-common-extensions and this now points to the compiler in the environment.

... and this actually solved the problem :-) lddtree install/image_tools/lib/image_tools/showimage is now showing the resolved library:

showimage => install/image_tools/lib/image_tools/showimage (interpreter => /lib64/ld-linux-x86-64.so.2)
    librclcpp.so => $HOME/micromamba/envs/ros_env/lib/librclcpp.so

and I can run ros2 run image_tools cam2image without issues. Thanks.

I the ROS repos, there is a convenient package ros-dev-tools that will install all required build tools to build packages. It would be nice if this could be available too for robostack.

Can you report the content of your environment (i.e. micromamba list)?

In theory you should not need to set LD_LIBRARY_PATH to ensure that the loader can find librclcpp.so. However, the location of the library you report is strange, if you environment is ros_env you should be able to find the library at micromamba/envs/ros_env/lib/librclcpp.so.

You are right, the library is at micromamba/envs/ros_env/lib/librclcpp.so. I forgot to update the index before searching for the file.

traversaro commented 10 months ago

I the ROS repos, there is a convenient package ros-dev-tools that will install all required build tools to build packages. It would be nice if this could be available too for robostack.

That makes indeed sense (even at conda-forge levels, if colcon is removed). I find myself installing complers cmake pkg-config make ninja everywhere, having something like build-essential can be useful.