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

今天在qt平台下调用摄像头发现如下错误:

在这里插入图片描述
一开始本人看错误是未定义是觉得头文件没有添加,一查看显然不是,咨询好友后发现,是lib的动态库没有添加完全。
这里给出解决方法·在.pro文件夹下添加:

LIBS+=/usr/local/lib/libopencv_shape.so
LIBS+=/usr/local/lib/libopencv_videoio.so

即可
添加完的pro如下图:
在这里插入图片描述
小编同时简单解释一下,pro文件的作用
INCLUDEPATH 主要是添加头文件
LIBS 主要是添加动态库
opencv可能用到的动态库都在/usr/local/lib/这个文件夹下,如下图:
在这里插入图片描述

发布了39 篇原创文章 · 获赞 25 · 访问量 3万+
展开阅读全文

请教:尝试opencv2.4.13在linux下编译程序的报错

11-21

源代码:#include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> using namespace cv; int main() { VideoCapture cap(0); if(!cap.isOpened()) { return -1; } Mat frame; bool stop = false; while(!stop) { cap.read(frame); imshow("Video",frame); if(waitKey(30)==27) //Esc键退出 { stop = true; } } return 0; } 报错:~$ g++ -o opencvq opencv.cpp /tmp/ccQJKVIi.o: In function `main': opencv.cpp:(.text+0x29): undefined reference to `cv::VideoCapture::VideoCapture(int)' opencv.cpp:(.text+0x38): undefined reference to `cv::VideoCapture::isOpened() const' opencv.cpp:(.text+0x80): undefined reference to `cv::VideoCapture::read(cv::Mat&)' opencv.cpp:(.text+0xf9): undefined reference to `cv::Mat::ones(cv::Size_<int>, int)' opencv.cpp:(.text+0x146): undefined reference to `cv::VideoCapture::read(cv::Mat&)' opencv.cpp:(.text+0x33d): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)' opencv.cpp:(.text+0x356): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)' opencv.cpp:(.text+0x36f): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)' opencv.cpp:(.text+0x3a1): undefined reference to `cv::addWeighted(cv::_InputArray const&, double, cv::_InputArray const&, double, double, cv::_OutputArray const&, int)' opencv.cpp:(.text+0x3ba): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)' opencv.cpp:(.text+0x3fd): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)' opencv.cpp:(.text+0x425): undefined reference to `cv::waitKey(int)' opencv.cpp:(.text+0x489): undefined reference to `cv::VideoCapture::~VideoCapture()' opencv.cpp:(.text+0x51a): undefined reference to `cv::VideoCapture::~VideoCapture()' /tmp/ccQJKVIi.o: In function `cv::Mat::~Mat()': opencv.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)' /tmp/ccQJKVIi.o: In function `cv::Mat::release()': opencv.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference to `cv::Mat::deallocate()' /tmp/ccQJKVIi.o: In function `cv::Mat::operator()(cv::Rect_<int> const&) const': opencv.cpp:(.text._ZNK2cv3MatclERKNS_5Rect_IiEE[_ZNK2cv3MatclERKNS_5Rect_IiEE]+0x27): undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Rect_<int> const&)' collect2: error: ld returned 1 exit status 第一次使用,在此请教各位前辈,谢谢了 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览