You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

带黑名单参数运行catkin_make run_tests时遇链接错误求助

Issue with catkin_make run_tests Using CATKIN_BLACKLIST_PACKAGES - Cannot Find -lsr_interpolation

Problem Breakdown

Let me restate your issue to make sure I've got it right:

  • You're working on Ubuntu 16.04 with ROS Kinetic.
  • Cloned the sr-ros-interface-ethercat repo, checked out F#SRC-2546_new_thumb_calibration_kinetic_devel, and installed all dependencies.
  • Regular catkin_make and catkin_make run_tests work perfectly with no errors.
  • But when running the CI build command (with a long CATKIN_BLACKLIST_PACKAGES list and coverage flags), you hit a linker error:

    /usr/bin/ld: cannot find -lsr_interpolation
    collect2: error: ld returned 1 exit status
    sr-ros-interface-ethercat/sr_robot_lib/CMakeFiles/sr_hand_lib.dir/build.make:504: recipe for target '/home/user/workspace/devel/lib/libsr_hand_lib.so' failed

You mentioned sr_interpolation compiles normally in non-blacklisted builds—so this problem is specific to the blacklisted test run with coverage flags.

Likely Causes

  1. Blacklisted Package is a Critical Dependency: Your CATKIN_BLACKLIST_PACKAGES includes sr_interpolation, but sr_hand_lib (which is being built for tests) explicitly depends on it. When you blacklist sr_interpolation, Catkin skips building it—but since you're using new compile flags (--coverage etc.), the existing compiled version of sr_interpolation doesn't match the new build context, or the linker can't locate it in the reconfigured environment.
  2. Coverage Flags Require a Full Rebuild: The --coverage flags change how binaries are compiled and linked. Even if sr_interpolation was built before, running catkin_make run_tests with new CXX flags triggers a reconfiguration. Since sr_interpolation is blacklisted, it doesn't get rebuilt with the same coverage flags, so the linker can't find a compatible version of libsr_interpolation.so.
  3. Catkin Make Dependency Resolution Quirk: ROS Kinetic's catkin_make has known limitations with handling blacklists during test runs compared to regular builds. It might not properly resolve transitive dependencies when packages are blacklisted, even if they were built previously.

Solutions to Try

1. Remove sr_interpolation from the Blacklist

Since sr_hand_lib depends on sr_interpolation to link successfully, it shouldn't be in the blacklist. Modify your CI command to exclude sr_interpolation from CATKIN_BLACKLIST_PACKAGES:

catkin_make run_tests -DCATKIN_BLACKLIST_PACKAGES="sr_msgs_common;sr_run_trajectories;sr_logging_common;sr_utilities_common;sr_world_generator;sr_watchdog;sr_description_common;sr_description;sr_common;sr_robot_msgs;sr_dynamic_time_warping;ros_ethercat_eml;sr_ur_arm_config;sr_config;sr_ethercat_hand_config;ros_ethercat_loop;ros_ethercat_model;ros_ethercat_hardware;ros_ethercat;sr_mechanism_controllers;sr_hardware_interface;sr_hand;sr_gazebo_sim;sr_utilities;sr_mechanism_model;sr_core;sr_tactile_sensors" -DCMAKE_CXX_FLAGS=" --coverage -fprofile-arcs -ftest-coverage"

This ensures sr_interpolation is built with the same coverage flags as sr_hand_lib, allowing the linker to find it.

2. Pre-Build sr_interpolation with Coverage Flags

If you absolutely need to keep sr_interpolation in the blacklist (though this doesn't make logical sense given the dependency), pre-build it separately with the coverage flags before running the test command:

# First build sr_interpolation with coverage flags
catkin_make --pkg sr_interpolation -DCMAKE_CXX_FLAGS=" --coverage -fprofile-arcs -ftest-coverage"
# Then run the blacklisted test command
catkin_make run_tests -DCATKIN_BLACKLIST_PACKAGES="sr_msgs_common;sr_run_trajectories;sr_logging_common;sr_utilities_common;sr_world_generator;sr_watchdog;sr_description_common;sr_description;sr_common;sr_robot_msgs;sr_interpolation;sr_dynamic_time_warping;ros_ethercat_eml;sr_ur_arm_config;sr_config;sr_ethercat_hand_config;ros_ethercat_loop;ros_ethercat_model;ros_ethercat_hardware;ros_ethercat;sr_mechanism_controllers;sr_hardware_interface;sr_hand;sr_gazebo_sim;sr_utilities;sr_mechanism_model;sr_core;sr_tactile_sensors" -DCMAKE_CXX_FLAGS=" --coverage -fprofile-arcs -ftest-coverage"

This ensures the correct version of libsr_interpolation.so exists in the devel/lib directory when sr_hand_lib tries to link against it.

3. Switch to catkin build (More Reliable Dependency Handling)

catkin_make is known for less robust dependency management compared to catkin build (from the catkin_tools package). Try using catkin build instead, which handles blacklists and test runs more consistently:

# Install catkin_tools if you haven't already
sudo apt-get install ros-kinetic-catkin-tools
# Clean previous build artifacts
catkin clean
# Run tests with blacklist and coverage flags
catkin build --blacklist sr_msgs_common sr_run_trajectories sr_logging_common sr_utilities_common sr_world_generator sr_watchdog sr_description_common sr_description sr_common sr_robot_msgs sr_interpolation sr_dynamic_time_warping ros_ethercat_eml sr_ur_arm_config sr_config sr_ethercat_hand_config ros_ethercat_loop ros_ethercat_model ros_ethercat_hardware ros_ethercat sr_mechanism_controllers sr_hardware_interface sr_hand sr_gazebo_sim sr_utilities sr_mechanism_model sr_core sr_tactile_sensors --cmake-args -DCMAKE_CXX_FLAGS=" --coverage -fprofile-arcs -ftest-coverage" --run-tests

Verification Steps

After trying any of the above solutions:

  1. Clean your workspace with catkin clean (or catkin_make clean) to remove old build artifacts.
  2. Re-run the modified CI command.
  3. Check if the linker error is resolved and the tests run successfully.

内容的提问来源于stack exchange,提问作者Mike_k

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:16:01