基本c ++程序中UBUNTU LTS中的Opencv错误

问题描述 投票:0回答:1

我在UBUNTU 18.04上为C ++安装了opencv。我在github源代码上使用了cmake并在opencv / release中构建。但是甚至编写一个包含'''#include'''在使用g ++编译时引起错误。错误报告是:

enter image description here

`
In file included from /usr/include/opencv2/highgui.hpp:51,
                 from main.cpp:1:
/usr/include/opencv2/videoio.hpp:928:83: error: invalid use of incomplete type ‘struct cv::DefaultDeleter<CvCapture>’
 template<> CV_EXPORTS void DefaultDeleter<CvCapture>::operator ()(CvCapture* obj) const;
                                                                                   ^~~~~
In file included from /usr/local/include/opencv2/core/cvstd.hpp:81,
                 from /usr/local/include/opencv2/core/base.hpp:58,
                 from /usr/local/include/opencv2/core.hpp:54,
                 from /usr/include/opencv2/highgui.hpp:46,
                 from main.cpp:1:
/usr/local/include/opencv2/core/cvstd_wrapper.hpp:32:29: note: declaration of ‘struct cv::DefaultDeleter<CvCapture>’
 template<typename Y> struct DefaultDeleter;
                             ^~~~~~~~~~~~~~
In file included from /usr/include/opencv2/highgui.hpp:51,
                 from main.cpp:1:
/usr/include/opencv2/videoio.hpp:929:91: error: invalid use of incomplete type ‘struct cv::DefaultDeleter<CvVideoWriter>’
 template<> CV_EXPORTS void DefaultDeleter<CvVideoWriter>::operator ()(CvVideoWriter* obj) const;
                                                                                           ^~~~~
In file included from /usr/local/include/opencv2/core/cvstd.hpp:81,
                 from /usr/local/include/opencv2/core/base.hpp:58,
                 from /usr/local/include/opencv2/core.hpp:54,
                 from /usr/include/opencv2/highgui.hpp:46,
                 from main.cpp:1:
/usr/local/include/opencv2/core/cvstd_wrapper.hpp:32:29: note: declaration of ‘struct cv::DefaultDeleter<CvVideoWriter>’
 template<typename Y> struct DefaultDeleter;
`
Edit: same output on
g++ main.cpp `pkg-config --cflags --libs opencv` -o out. 
c++ opencv g++ static-libraries static-linking
1个回答
0
投票

您需要将OpneCV与程序链接。

尝试以下操作:g++ main.cpp pkg-config --cflags --libs opencv -o out

[pkg-config --cflags --libs opencv将添加include_dirslink_directories

更多说明here

© www.soinside.com 2019 - 2024. All rights reserved.