I have the following in my CMakeLists.txt
project(robot)
...
add_library(${PROJECT_NAME} src/Robot.cpp)
ament_target_dependencies(${PROJECT_NAME} rclcpp)
add_executable(node src/node.cpp)
ament_target_dependencies(node ${PROJECT_NAME} ${PROJECT_NAME}_msgs rclcpp) # <--- this line
However, when compiling with colcon build
, it gives the following error
ament_target_dependencies() the passed package name 'robot' was not found
for the highlighted line.
How do I let nodes use libraries that were compiled in the same package?
With ROS1 catkin, this was done with the following lines
add_dependencies(node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(node ${PROJECT_NAME} ${catkin_LIBRARIES})
which I assume is now combined into a single ament_target_dependencies()
?
Originally posted by Rufus on ROS Answers with karma: 1083 on 2021-02-11
Post score: 1