Ask Your Question

Revision history [back]

mat.hpp:1137: undefined reference to `vtable for cv::_InputArray'

I keep seeing this error

/usr/include/opencv2/core/mat.hpp:1137: undefined reference to `vtable for cv::_InputArray'

at various locations. The below code is an excerpt from the DFT tutorial

https://docs.opencv.org/3.4/d8/d01/tutorial_discrete_fourier_transform.html

 cv::Mat magI = planes[0];
 magI += cv::Scalar::all(1);

If I replace that line with magI = magI + cv::Scalar::all(1);

it works fine. Seems the += operator is not overloaded properly?

I guess this is a bug in my cv version? LL 1137 in that file is

template<typename _Tp> inline _InputArray::_InputArray(const _Tp* vec, int n)
    : flags(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type), obj((void*)vec), sz(n, 1) {}
//Below is 1137
inline _InputArray::_InputArray(const Scalar& s)
    : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&s), sz(1, 4) {}

template<typename _Tp> inline _InputArray::_InputArray(const Mat_<_Tp>& m)
    : flags(FIXED_TYPE + MAT + DataType<_Tp>::type), obj((void*)&m) {}

That returns not a template by a fixed type. Could that be the issue?