Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference to `cv::VideoCapture::VideoCapture(int)

Tags:

c++

opencv

i'm trying to use my webcam using C++ and OpenCV, but i'm gettin this error

(...):Images.cpp:(.text+0x27): undefined reference to cv::VideoCapture::VideoCapture(int)

(...):Images.cpp:(.text+0x38): undefined reference to cv::VideoCapture::~VideoCapture()

(...):Images.cpp:(.text$_ZN2cv6StringD1Ev[_ZN2cv6StringD1Ev]+0x11): undefined reference to cv::String::deallocate() ...

My code:

#include <iostream>
#include <string.h>
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/videoio/videoio.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/video.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace std;
using namespace cv;


int main(int argc, char const *argv[])
{
    VideoCapture cap(0);
    return 0;
}
like image 946
Felipe Machado Avatar asked Sep 04 '17 23:09

Felipe Machado


1 Answers

I faced the same issue with respect to opencv version 3.4.3.

With reference to this example, I figured out that I was not including the libopencv_videoio. Once I added it to the project, the build was successful.

In opencv version 3, I think we also need to include the library -lopencv_videoio to use VideoCapture.

like image 75
vishwanath_hugar Avatar answered Oct 13 '22 19:10

vishwanath_hugar