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

Should I link ${catkin_LIBRARIES} to my library, or to executables?

asked 2020-09-03 06:50:04 -0600

ItsTimmy gravatar image

Here's an excerpt from my CMakeLists.txt:

add_library(my_lib <some source files>)
target_link_libraries(my_lib ${catkin_LIBRARIES})

add_executable(my_node <some source files)
target_link_libraries(my_node my_lib)

I found that everything works fine if I link ${catkin_LIBRARIES} to either my_node or my_lib. So is either way preferred for any reason? Is there any convention?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-09-03 10:24:27 -0600

Dirk Thomas gravatar image

The convention is that you should link all dependencies needed to a target. On Windows that is even required.

Without known what exactly is in your library / executable I can't answer the question.

If the source files of your library include headers from dependencies found with find_package(catkin REQUIRED COMPONENTS ...) you should link ${catkin_LIBRARIES} to your libraries. And if the source files of your executable include headers from dependencies found with find_package(catkin REQUIRED COMPONENTS ...) (and not transitively through headers from your library) you should link ${catkin_LIBRARIES} to your executable.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-09-03 06:50:04 -0600

Seen: 405 times

Last updated: Sep 03 '20