g++ cv.cpp -o cv -I /usr/local/include/opencv
-L /usr/local/lib -lm -lcv -lhighgui -lcvaux
Error:
/usr/bin/ld: cannot find -lcv
collect2: ld returned 1 exit status
Code:
#include <cv.h>
#include <ml.h>
#include <cxcore.h>
//#include <cxtypes.h>
#include <highgui.h>
int main(int argc, char* argv[])
{
IplImage* img = cvLoadImage( "bal.png" );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
return 0;
}
It's 32 bit,
locate libcv
/usr/lib/libcv.so.2.1
/usr/lib/libcv.so.2.1.0
`pkg-config --cflags --libs opencv`
-I/usr/local/include/opencv
-I/usr/local/include /usr/local/lib/libopencv_calib3d.so
/usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so
/usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so
/usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so
/usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so
/usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so
/usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_photo.so
/usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_ts.so
/usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so
Installed OpenCV-2.4.0 in /usr/local, I also have a system python-opencv. Where am i doing the mistake? What should i do?
As seen from the changelog published on the OpenCV site (for version 2.2), the library names have changed from version 2.2 onwards, so the library names used to link for version 2.1 cannot be used to compile with version 2.4 (i.e. libcv.so
which is linked through -lcv
is not valid library name for version > 2.1 as so on ). You need to pass the libraries which are part of the new version of OpenCV (which have been listed through pkg-config
command). You can make use of pkg-config
to pass the compiler & linker flags something on these lines : g++ cv.cpp -o cv $(pkg-config --cflags --libs opencv)
.
Hope this helps!
You have version 2.1 in /usr/lib
while the new installed version 2.4 is in /usr/local/lib
, need to fix that and make sure the lib ld
finds is the one you compiled/linked for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With