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

CMakeLists pkg-config opencv C++

asked 2016-12-25 22:15:48 -0500

sora gravatar image

updated 2016-12-25 22:18:16 -0500

I made program with "opencv2/nonfree/features2d.hpp" like this include.

#include "opencv2/nonfree/features2d.hpp"

When I compile the program, I need some option like this.

g++ filename.cpp `pkg-config opencv --cflags --libs`

These are no error. But I don't know how to write this on CMakeLists.

When I do catkin_make, these are same error that I compiled without option.

Please tell me.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-27 01:10:38 -0500

ahendrix gravatar image

A quick google search for "cmake opencv" turns up:

Following the example there, it looks like you need to add the following to your CMakeLists:

find_package( OpenCV REQUIRED )

And then link to OpenCV with:

target_link_libraries( your_executable ${OpenCV_LIBS} )
edit flag offensive delete link more


I thought these are no link of nonfree in OpenCV.

But, I can solve it by your advice.


sora gravatar image sora  ( 2016-12-27 01:33:12 -0500 )edit

Question Tools



Asked: 2016-12-25 22:15:48 -0500

Seen: 1,238 times

Last updated: Dec 27 '16