Reputation: 63
I am following a tutorial about OpenCV, but when I build my project, a message of error is displayed:
#include <highgui.h>
#include <cv.h>
int main (int argc, char **argv) {
cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCreateFileCapture("code.avi");
IplImage *frame;
while (1) {
frame = cvQueryFrame(capture);
if (!frame)
break;
cvShowImage("Example2", frame);
char c = cvWaitKey(33);
if (c == 27)
break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Example2");
return 0;
}
The error message is this:
...undefined reference to cvCreateFileCapture
...undefined reference to cvQueryFrame
...undefined reference to cvReleaseCapture
I imported all the libraries and include files. And the "Example1" worked just fine.
I am using Ubuntu 14.04 (Trusty Tahr) and Eclipse.
Upvotes: 0
Views: 1195
Reputation: 796
You have probably just forgotten to order the compiler to link the library which provides these functions. The name of the library that does might depend on the OpenCV version you are using. For OpenCV 3.0, try linking the lib videoio.
You can safely find out which library provides your function by using grep cvSomeFunction *.so
in the folder where your OpenCV libraries have been installed to. To be even more sure, do nm someOpenCVLib.so | grep cvSomeFunction
and check see the "T" output which tells you that the library provides this function:
00013570 T cvSomeFunction
Upvotes: 1