Precedence of colcon_ws rclcpp over /opt/ros/crystal version?
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/libament_index_cpp.so /usr/lib/libPocoFoundation.so.50 /opt/ros/crystal/lib/libconsole_bridge.so.0.4 /opt/ros/crystal/lib/libclass_loader.so /home/lucasw/colcon_ws/install/rclcpp/lib/librclcpp.so /opt/ros/crystal/lib/librcl.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_c.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_cpp.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_generator_c.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_fastrtps_c.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_introspection_c.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_introspection_cpp.so /opt/ros/crystal/lib/librmw_implementation.so -lpthread /opt/ros/crystal/lib/librmw.so /opt/ros/crystal/lib/librcl_logging_noop.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_c.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_generator_c.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_c.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_cpp.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_c.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.so /opt/ros/crystal/lib/librosidl_typesupport_introspection_c.so /opt/ros/crystal/lib/librosidl_typesupport_introspection_cpp.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_generator_c.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_c.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_cpp.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_introspection_c.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_introspection_cpp.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_c.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so /opt/ros/crystal/lib/librosidl_typesupport_cpp.so /opt/ros/crystal/lib/librosidl_typesupport_c.so /opt/ros/crystal/lib/librosidl_generator_c.so /opt/ros/crystal/lib/librcl_yaml_param_parser.so /opt/ros/crystal/lib/librcutils.so -lpthread -ldl -lrt /usr/lib/x86_64-linux-gnu/libpcre.so /usr/lib/x86_64-linux-gnu/libz.so
colcon will then be tricked into relinking the .o built from the right includes if ...
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.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.
that's not a guarantee that you won't break ABI (and is the reason patterns like PIMPL exist).
First of all
colcon
has nothing to do with this behavior. The include directories are exclusively defined in CMake.Please share the CMake code of the package
ros2_cpp_py
which is using the wrong include directories.https://github.com/lucasw/ros2_cpp_py...
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.
Please provide steps to reproduce the above error. Just building the referenced repository doesn't fail for me.