Ask Your Question

Precedence of colcon_ws rclcpp over /opt/ros/crystal version?

asked 2019-02-16 10:27:34 -0600

lucasw gravatar image

updated 2019-02-19 17:42:54 -0600

I forked rclcpp crystal branch and made some modification in my colcon_ws, and then made changes to another package that depends on those modifications, but the includes still point to the opt version.

In file included from /opt/ros/crystal/include/rclcpp/executors/single_threaded_executor.hpp:28:0,
                 from /opt/ros/crystal/include/rclcpp/executors.hpp:22,
                 from /opt/ros/crystal/include/rclcpp/rclcpp.hpp:144,
                 from /home/lucasw/colcon_ws/src/ros2_cpp_py/src/node_init.cpp:35:

ros2 pkg list rclcpp shows the location of the modified version.

Removing the entirety of install and build didn't and rebuilding didn't help (in other cases such as changing a msg or srv deleting the install and build for the altered package seems to be necessary).

If I go into build/ros2_cpp_py and run make VERBOSE=1 I see the opt include is coming first, which corresponds to the order in CMakeFiles/node_init.dir/DependInfo.cmake. I can manually fix the order and build (editing that DependInfo.cmake didn't work, output from it must be cached somewhere) then:

/usr/bin/c++  -DPOCO_NO_AUTOMATIC_LIBS -I/home/lucasw/colcon_ws/src/ros2_cpp_py/include -I/home/lucasw/colcon_ws/install/rclcpp/include -I/opt/ros/crystal/include -Wall -Wextra -Wpedantic -std=gnu++14 -o CMakeFiles/node_init.dir/src/node_init.cpp.o -c /home/lucasw/colcon_ws/src/ros2_cpp_py/src/node_init.cpp
/usr/bin/c++     CMakeFiles/node_init.dir/src/node_init.cpp.o  -o node_init -Wl,-rpath,/home/lucasw/colcon_ws/install/rclcpp/lib:/opt/ros/crystal/lib: /opt/ros/crystal/lib/ /usr/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /home/lucasw/colcon_ws/install/rclcpp/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ -lpthread /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ /opt/ros/crystal/lib/ -lpthread -ldl -lrt /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/

colcon will then be tricked into relinking the .o built from the right includes if ... (more)

edit retag flag offensive close merge delete


Wouldn't changing a pkg as "far down" in the dependency trees as rclcpp have the potential to create ABI compatibility issues, leading to many pkgs needing to be recompiled anyway? That's not a reason for overlaying not working btw, just an observation/question prompted by your last comment.

gvdhoorn gravatar image gvdhoorn  ( 2019-02-16 11:35:41 -0600 )edit

That's the kind of issue I'm expecting, but so far the changes are additive and the only nodes I'm using here are ones that are getting recompiled anyhow. I think the compositional architecture of Node is going to help, the components I don't change are insulated from breaking.

lucasw gravatar image lucasw  ( 2019-02-16 12:34:39 -0600 )edit

but so far the changes are additive

that's not a guarantee that you won't break ABI (and is the reason patterns like PIMPL exist).

gvdhoorn gravatar image gvdhoorn  ( 2019-02-17 04:33:32 -0600 )edit

First of all colcon has nothing to do with this behavior. The include directories are exclusively defined in CMake.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-02-19 12:55:59 -0600 )edit

Please share the CMake code of the package ros2_cpp_py which is using the wrong include directories.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-02-19 12:57:14 -0600 )edit

Oh it's the order of the dependencies in ament_target_dependencies, rclcpp needs to be before any other packages outside of the current ws dependent on it.

lucasw gravatar image lucasw  ( 2019-02-19 15:25:55 -0600 )edit

Please provide steps to reproduce the above error. Just building the referenced repository doesn't fail for me.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-02-19 16:55:26 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2019-02-19 18:14:54 -0600

Dirk Thomas gravatar image

I was able to reproduce the problem with the steps. While the function was supposed to order the include dirs automatically it fails to do so correctly on non-Windows platforms where the separator for the paths in AMENT_PREFIX_PATH is : (instead of ; as on Windows and in CMake).

Please see for the proposed patch. You should be able to apply the same diff to the file installed in /opt/ros/crystal/share/ament_cmake_include_directories/cmake/ament_include_directories_order.cmake and your next build should succeed.

edit flag offensive delete link more

answered 2019-02-19 15:30:06 -0600

lucasw gravatar image

updated 2019-02-19 18:49:43 -0600

These options don't solve the problem, they are just workarounds:

Changing this




avoids the problem- ament_index_cpp and/or class_loader are dependent on rclcpp so their includes come first. That doesn't seem like a good requirement to have so alternatively I would have to bring in sources of those two packages and anything else they depend on that also depends on rclcpp- but that is too much work to do manually so ros2_ws sources for everything is easier and less error prone, follow instead of any of this.

edit flag offensive delete link more


This is certainly not the proper fix for the problem. The CMake function is supposed to order the include directories based on the order of your workspaces:

Dirk Thomas gravatar image Dirk Thomas  ( 2019-02-19 16:50:06 -0600 )edit

This looks like the relevant code:

ament_include_directories_order(ordered_include_dirs ${include_dirs})

lucasw gravatar image lucasw  ( 2019-02-19 17:54:41 -0600 )edit
lucasw gravatar image lucasw  ( 2019-02-19 17:57:15 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-02-16 10:27:34 -0600

Seen: 485 times

Last updated: Feb 19 '19