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

catkin_simple: Implicitly linking of yaml-cpp library fails when building in install space

asked 2020-03-12 09:42:23 -0500

prex gravatar image

I'm using the yaml-cpp system dependency in my package.xml when building with catkin_simple:

<depend>yaml-cpp</depend>

However, this doesn't work when using catkin config --install. I need to explicitly link the yaml-cpp library in my CMakeLists to make it build:

target_link_libraries(${PROJECT_NAME} yaml-cpp)

Otherwise, I'm getting undefined reference errors. Can someone explain this to me since catkin_simple implicitly links other system dependencies just fine.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-12 09:57:12 -0500

gvdhoorn gravatar image

updated 2020-03-12 10:38:38 -0500

I recently ran into this while fixing some catkin_lint problems.

See fkie/catkin_lint#78.

In short: yaml-cpp does not play nice with CMake's conventions. The name of the find-script uses yaml-cpp as the name, but the variables defined by it use YAML_CPP as the prefix.

catkin_simple (and actually regular Catkin as well, so I'm not sure this is a problem of catkin_simple per se), rightly assume if a find-script is called FindSomething.cmake, all variables defined by/in it are prefixed by Something (note capitalisation).

yaml-cpp does not follow this convention and this causes your linking problems (ie: CMake/Catkin generates code to link against yaml-cpp_LIBRARIES, but the variable is actually called YAML_CPP_LIBRARIES).

edit flag offensive delete link more

Comments

Oh, ok. And target_link_libraries(${PROJECT_NAME} yaml-cpp) solves this?

prex gravatar image prex  ( 2020-03-12 10:35:22 -0500 )edit

No. I would call that a work-around.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-12 10:38:25 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-03-12 09:42:23 -0500

Seen: 1,392 times

Last updated: Mar 12 '20