0
$\begingroup$

Rosanswers logo

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?


Originally posted by ItsTimmy on ROS Answers with karma: 3 on 2020-09-03

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Dirk Thomas with karma: 16276 on 2020-09-03

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.