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

add local opencv to path

asked 2017-06-19 08:46:12 -0500

ashwath1993 gravatar image

I want to compile my ROS node with the opencv which is at /usr/local/ I have tried the following rosanswers
I could compile my code without errors. But when i run the node, i get the following error.

undefined reference to `cv::cuda::createStereoBM(int, int)'

I checked my CMakeCache.txt to see the path for the opencv directories and I get this


The libraries for cudastereo.hpp are in /usr/local/include and not in /usr/local/share. How do I get my CMakeLists.txt to get the correct OpenCV as I am able to run the code outside ROS with no errors. My CMakeLists.txt is as follows

find_package(OpenCV REQUIRED
PATHS /usr/local
add_executable(flir_node src/flir_node.cpp)
target_link_libraries(flir_node ${catkin_LIBRARIES} )

Any suggestions? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-07-12 03:24:22 -0500

ashwath1993 gravatar image

This is solved by mentioning the library location and the path separately in the CMakeLists.txt

set(OpenCV_INCLUDE_DIRS /usr/local/)

set(OpenCV_LIBS /usr/local/lib/

This fixed the problem on most cases.

If catkin fails to compile with the local openCV after setting the CMakeLists.txt as above, open the CMakeCache.txt after it compiles and change the opencv path in that and recompile. Works!

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-06-19 08:46:12 -0500

Seen: 2,346 times

Last updated: Jul 12 '17