我在UBUNTU 18.04上为C ++安装了opencv。我在github源代码上使用了cmake并在opencv / release中构建。但是甚至编写一个包含'''#include'''在使用g ++编译时引起错误。错误报告是:
`
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.
您需要将OpneCV
与程序链接。
尝试以下操作:g++ main.cpp pkg-config --cflags --libs opencv -o out
[pkg-config --cflags --libs opencv
将添加include_dirs
和link_directories
。
更多说明here。