ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

yaml-cpp in ROS2 linking errors

asked 2019-09-24 09:59:41 -0600

LeoE gravatar image

Hi everybody,

Following problem occurred: I'm trying to use yaml-cpp in a ROS2 package and it returns loads of linking errors ("undefined reference to ...") I have linked yaml-cpp to the project in the CMakeLists.txt and it throws no errors what so ever, so I assumed everything went fine. Did something change with the yaml-cpp library for ROS2? Or do i have a mistake in my CMakeList?

Important parts of CMakeLists.txt:

find_package(yaml-cpp REQUIRED)

# include directories
include_directories(
  include
  include/multi_node_controller
  include/multi_node_controller/auto_generated
  ${YAML_CPP_INCLUDEDIR}
)

add_executable(function_parser src/function_parser.cpp)

ament_target_dependencies(function_parser
                          rclcpp
                          std_msgs
                          custom_msgs
                          yaml-cpp)

Or do I need to include it in the package.xml?

Thanks for any help!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-09-24 10:36:08 -0600

LeoE gravatar image

Ok, I figured it out myself. I thought ament_target_dependencies invokes target_link_libraries, so I thought everything should be as in ROS1, but apparently you need an extra call of target_link_libraries(${PROJECT_NAME} ${YAML_CPP_LIBRARIES}) after the ament_target_dependencies(...).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-09-24 09:59:41 -0600

Seen: 2,391 times

Last updated: Sep 24 '19