# Undefined reference to \`cv::CascadeClassifier::empty() const'

**URL:** <https://forum.opencv.org/t/undefined-reference-to-cv-empty-const/17387>\
**Category:** C++\
**Tags:** build\
**Created:** [April 23, 2024, 8:28am UTC](https://forum.opencv.org/t/undefined-reference-to-cv-empty-const/17387 "2024-04-23T08:28:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MingZi\_Jia](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/mingzi_jia/32/10229_2.png) [@MingZi\_Jia](https://forum.opencv.org/u/MingZi_Jia)\
**Post date:** [April 23, 2024, 8:28am UTC](https://forum.opencv.org/t/undefined-reference-to-cv-empty-const/17387/1 "2024-04-23T08:28:37Z")

</div>

**when i write:**  
CascadeClassifier faceCascade;  
faceCascade.load(“…/peripheral/cv\_zone/Resources/haarcascade\_frontalface\_default.xml”);  
if (faceCascade.empty()) {  
cout \<\< “XML file not loaded” \<\< endl;  
}  
**I got error as follows:**  
/usr/bin/ld: CMakeFiles/vedio\_opencv.dir/with\_opencv/src/cv\_zone\_Project3.cpp.o: in function `cv_zone_faceDetection()': cv_zone_Project3.cpp:(.text+0x80): undefined reference to `cv::CascadeClassifier::CascadeClassifier()’  
/usr/bin/ld: cv\_zone\_Project3.cpp:(.text+0xc5): undefined reference to `cv::CascadeClassifier::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: cv_zone_Project3.cpp:(.text+0xf2): undefined reference to `cv::CascadeClassifier::empty() const’  
/usr/bin/ld: cv\_zone\_Project3.cpp:(.text+0x1bf): undefined reference to `cv::CascadeClassifier::~CascadeClassifier()' /usr/bin/ld: cv_zone_Project3.cpp:(.text+0x299): undefined reference to `cv::CascadeClassifier::~CascadeClassifier()’  
collect2: error: ld returned 1 exit status  
make[2]: \*\*\* [CMakeFiles/vedio\_opencv.dir/build.make:331：/home/zero/openCV/chip\_phytium/opencv\_output/vedio\_opencv] 错误 1  
make[1]: \*\*\* [CMakeFiles/Makefile2:83：CMakeFiles/vedio\_opencv.dir/all] 错误 2  
make: \*\*\* [Makefile:91：all] 错误 2

**But when I trace the defination of CascadeClassifier , I can find it in objdetect.hpp .so I checked my CMakelist.txt ,it sames right**  
**Could someone help me ,please**

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [April 24, 2024, 5:27am UTC](https://forum.opencv.org/t/undefined-reference-to-cv-empty-const/17387/2 "2024-04-24T05:27:00Z")

</div>

this is a **linker** problem, please check, if you are correctly linking your code against the opencv\_objdetect lib.

also it seems to want `std::__cxx11` strings, so find out, if your program using it will have the same c++ flags, the lib was built with.
