How could I compile opencv programs outside ROS?
I installed the opencv-2.3.1 package through ROS, but there seems to be link errors when compiling opencv programs outside ROS.
I created a Makefile file with the following content
DisplayImage:DisplayImage.cpp
@g++ -L/usr/lib/ `pkg-config opencv-2.3.1 --cflags --libs` -o DisplayImage DisplayImage.cpp
But the compiling result is
XXX@ubuntu:~/Documents/programs/OpenCV$ make
/usr/bin/ld: cannot find -l/usr/lib/libopencv_contrib.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_legacy.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_objdetect.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_calib3d.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_features2d.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_video.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_highgui.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_ml.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_imgproc.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_flann.so.2.3.1
/usr/bin/ld: cannot find -l/usr/lib/libopencv_core.so.2.3.1
collect2: ld returned 1 exit status
make: *** [DisplayImage] Error 1
pkg-config --libs --cflags opencv-2.3.1
shows
-I/usr/include/opencv-2.3.1/opencv -I/usr/include/opencv-2.3.1 -l/usr/lib/libopencv_contrib.so.2.3.1 -l/usr/lib/libopencv_legacy.so.2.3.1 -l/usr/lib/libopencv_objdetect.so.2.3.1 -l/usr/lib/libopencv_calib3d.so.2.3.1 -l/usr/lib/libopencv_features2d.so.2.3.1 -l/usr/lib/libopencv_video.so.2.3.1 -l/usr/lib/libopencv_highgui.so.2.3.1 -l/usr/lib/libopencv_ml.so.2.3.1 -l/usr/lib/libopencv_imgproc.so.2.3.1 -l/usr/lib/libopencv_flann.so.2.3.1 -l/usr/lib/libopencv_core.so.2.3.1
How could I fix the problem? Thank you.
Originally posted by MichaelHsu170 on ROS Answers with karma: 67 on 2011-11-11
Post score: 2