error: undefined reference to `cv::imread(cv::String const&, int)' 解决方法

编译时出现下列错误:

undefined reference to 'cv::imread(cv::String const&, int)'
undefined reference to 'cv::String::deallocate()'
undefined reference to 'cv::imread(cv::String const&, int)'
undefined reference to 'cv::String::deallocate()'
undefined reference to 'cv::String::allocate(unsigned long)'
undefined reference to 'cv::String::allocate(unsigned long)'
undefined reference to 'cv::String::deallocate()'
undefined reference to 'cv::String::deallocate()'
解决方法:在CMakeLists.txt加入安装OpenCV的版本号:

find_package( OpenCV REQUIRED )
更改为
find_package( OpenCV 3 REQUIRED ) 。

posted @ 2022-04-26 20:54  小丑_jk  阅读(844)  评论(0编辑  收藏  举报