"colcon build --merge-install" change the environment variable "LD_LIBRARY_PATH"
After I run the command
colcon build --merge-install --install-base /opt/ros/$ROS_DISTRO
I found the environment variable "LDLIBRARYPATH" changed from
/opt/ros/galactic/lib/x86_64-linux-gnu:/opt/ros/galactic/lib
to /opt/ros/galactic/lib
. And then it caused it cannot find libraries under /opt/ros/galactic/lib/x86_64-linux-gnu.
Here are steps you can reproduce this error:
You can use docker image "public.ecr.aws/docker/library/ros:galactic"
put demonodescpp in your "src" folder. This demo needs
libconsole_bridge.so.1.0
which is under/opt/ros/galactic/lib/x86_64-linux-gnu
run
colcon build --merge-install --install-base "/opt/ros/galactic"
check the environment variable "LDLIBRARYPATH":
echo $LD_LIBRARY_PATH
. You should get/opt/ros/galactic/opt/yaml_cpp_vendor/lib:/opt/ros/galactic/lib/x86_64-linux-gnu:/opt/ros/galactic/lib
save this container as a docker image. You can run
docker ps
to find this container ID. Then run ``` docker commit "container ID" "image name"start a container of the new docker image. Then check check the environment variable "LDLIBRARYPATH":
echo $LD_LIBRARY_PATH
``You should get
/opt/ros/galactic/lib`Run the demo
ros2 run demo_nodes_cpp talker
. You will get the error/opt/ros/galactic/lib/demo_nodes_cpp/talker: error while loading shared libraries: libconsole_bridge.so.1.0: cannot open shared object file: No such file or directory
There is no issue if only using colcon build
. So I suspect the cause of this is from --merge-install
.
Thank you for your help!
Asked by rwu on 2022-11-08 05:17:17 UTC
Comments