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

Linking OpenCV library (ROS2, C++)

asked 2020-08-15 21:44:31 -0600

mirella melo gravatar image

updated 2020-08-15 21:47:18 -0600

Hi!

I'd like to use the OpenCV library in a C++ project - ROS2 (building with colcon build).

I added in the CmakeList the following command:

find_package(OpenCV 3.4.0 REQUIRED)

And when I #include any OpenCV header in my main code, I have no errors, but when I call any function of it, I have linking errors. It may be missing something in the CmakeList, but I don't know exactly what...

I appreciate any help. Thanks!

edit retag flag offensive close merge delete

Comments

Are you linking the OpenCV library in the 'target_link_libraries' section?

Teo Cardoso gravatar image Teo Cardoso  ( 2020-08-15 21:59:42 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2020-08-16 11:34:32 -0600

updated 2020-08-16 11:35:02 -0600

Add OpenCV in ament target dependencies-

ament_target_dependencies(executable_name 
  rclcpp 
  OpenCV
..
..
..
other _packages
)
edit flag offensive delete link more

Comments

Thank you, guys!! It is working. o/

mirella melo gravatar image mirella melo  ( 2020-08-16 12:04:52 -0600 )edit

How did you know to add OpenCV? Are there docs on this?

psammut gravatar image psammut  ( 2022-06-01 19:39:08 -0600 )edit

Question Tools

Stats

Asked: 2020-08-15 21:44:31 -0600

Seen: 3,146 times

Last updated: Aug 16 '20