0
$\begingroup$

Rosanswers logo

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

/usr/local/share/OpenCV

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
NO_MODULE
PATHS /usr/local
NO_DEFAULT_PATH)
include_directories(
${catkin_INCLUDE_DIRS}
)
add_executable(flir_node src/flir_node.cpp)
target_link_libraries(flir_node ${catkin_LIBRARIES} )

Any suggestions? Thanks!


Originally posted by ashwath1993 on ROS Answers with karma: 70 on 2017-06-19

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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/libopencv_core.so)

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!


Originally posted by ashwath1993 with karma: 70 on 2017-07-12

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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