VideoCapture compile error

My code in Qt

LIBS += -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -lopencv_highgui

#include <opencv2/opencv.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/core/utility.hpp>

using namespace cv;

Mat frame;
VideoCapture cap = VideoCapture(0);
    imshow("image", frame);

When I build I get

/usr/bin/ld: main.o: undefined reference to symbol ‘_ZN2cv12VideoCaptureD1Ev’
/usr/bin/ld: //usr/lib/arm-linux-gnueabihf/ error adding symbols: >DSO missing from command line
collect2: error: ld returned 1 exit status

What may be a problem?

same problem as in your last question – you’re missing a library


also, for clarity, you should

#include <opencv2/videoio.hpp>

explicitly (it’s still in the highgui header for historic reasons)

(rule of thumb - you need a library for each module header you include …)

1 Like

Thank you so much! )