invalid use of incomplete type struct cv::DefaultDeleter<CvHaarClassifierCascade>
I am trying to build this c++ sample from docs: https://docs.opencv.org/4.1.2/db/d28/... But I am getting this error:
In file included from /home/stiv2/jsoft/research/casclass/main0.cpp:1:0:
/usr/include/opencv2/objdetect.hpp:166:111: error: invalid use of incomplete type ?struct cv::DefaultDeleter<CvHaarClassifierCascade>?
template<> CV_EXPORTS void DefaultDeleter<CvHaarClassifierCascade>::operator ()(CvHaarClassifierCascade* obj) const;
^~~~~
In file included from /usr/local/include/opencv4/opencv2/core/cvstd.hpp:81:0,
from /usr/local/include/opencv4/opencv2/core/base.hpp:58,
from /usr/local/include/opencv4/opencv2/core.hpp:54,
from /usr/include/opencv2/objdetect.hpp:47,
from /home/stiv2/jsoft/research/casclass/main0.cpp:1:
/usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:32:29: note: declaration of ?struct cv::DefaultDeleter<CvHaarClassifierCascade>?
template<typename Y> struct DefaultDeleter;
How can I fix it and what is the reason for it? I've built opencv with objdetect module.