Ask Your Question

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

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

prex gravatar image

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


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

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

gvdhoorn gravatar image

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

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


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

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

No. I would call that a work-around.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-12 10:38:25 -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

1 follower


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

Seen: 542 times

Last updated: Mar 12 '20