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;
}
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.
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