Rosanswers logo

I would like to compile a ros package skimap_ros with a local version on opencv. All my attempts at overriding the libraries in the CMakeLists.txt have failed ...it keeps taking the opencv from /usr. Does anyone know how to do this in ROS. Thank you\

getting erros of the form:

/usr/include/opencv2/nonfree/features2d.hpp:143:47: error: expected ‘,’ or ‘...’ before ‘<’ token void computeImpl( const Mat& image, vector& keypoints, Mat& descriptors ) const;

path is wrong should be /home/rjn/opencv-

have tried specifying on catkin build line

-DOpenCV_DIR="-L/home/rjn/opencv- -I/home/rjn/opencv-"


-DCPPFLAGS="-L/path/to/opencv2.4.9/lib -I/path/to/opencv2.4.9/include"

and overriding directly in CMakeLists

The directory: exist


Originally posted by rnunziata on ROS Answers with karma: 713 on 2017-10-05

Post score: 0


1 Answer 1


Rosanswers logo

It would be nice if you can share what have you tried but this is how I would do it:

find_package(OpenCV REQUIRED
   NO_MODULE #Should be optional, tells CMake to use config mode
   PATHS /usr/local # Tells CMake to look here
   NO_DEFAULT_PATH #and don't look anywhere else

Originally posted by ROSkinect with karma: 751 on 2017-10-06

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by BCJ on 2020-06-13:
Hello, I have two opencv folder under /usr/local which is opencv and opencv2. If I want to use opencv2 as the include library, then I should specific /usr/local/opencv2 in the PATHS option? Thanks in advance.

Comment by ROSkinect on 2020-06-14:
You can add next OpenCV the version you want to work with, for eg. find_package(OpenCV 4.01 REQUIRED ...


Your Answer

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