Reputation: 1
I am receiving an error when running CMake (actually rosmake) on my project. I have already installed OpenCV, but I get the following error:
Linking CXX shared library ../lib/libCornerHelper.so
/usr/bin/ld: cannot find -lopencv_contrib
/usr/bin/ld: cannot find -lopencv_legacy
/usr/bin/ld: cannot find -lopencv_stitching
/usr/bin/ld: cannot find -lopencv_gpu
/usr/bin/ld: cannot find -lopencv_objdetect
/usr/bin/ld: cannot find -lopencv_calib3d
/usr/bin/ld: cannot find -lopencv_features2d
/usr/bin/ld: cannot find -lopencv_video
/usr/bin/ld: cannot find -lopencv_highgui
/usr/bin/ld: cannot find -lopencv_ml
/usr/bin/ld: cannot find -lopencv_imgproc
/usr/bin/ld: cannot find -lopencv_flann
/usr/bin/ld: cannot find -lopencv_core
collect2: ld returned 1 exit status
make[3]: *** [../lib/libCornerHelper.so] Error 1
Does anyone know how to solve this?
Upvotes: 0
Views: 2326
Reputation: 1026
If you are using OpenCV in ROS, the appropriate link flags and paths should be picked up automatically if you have declared a dependency on opencv2 in your manifest.xml file.
If you are still having issues, I suggest you search ROS Answers and, if you don't find anything, ask your question there. That is the official ROS support forum and will likely get you a better answer to ROS specific problems than StackOverflow.
Upvotes: 0
Reputation: 1321
Apparently, he could not find opencv to link against your project. Did you install it in somewhere else other than /usr or /usr/local?
If so, you need to add the path to LD_LIBRARY_PATH variable and so on. What does your system say when you run this?
pkg-config --cflags --libs opencv
If you get something like this, then your system is ok.
-I/opt/opencv/include/opencv -I/opt/opencv/include -L/opt/opencv/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
but if you don't, your system is not able to find it and cmake will not find it either:
Package opencv was not found in the pkg-config search path. Perhaps you should add the directory containing `opencv.pc' to the PKG_CONFIG_PATH environment variable No package 'opencv' found
Upvotes: 2