1. 程式人生 > >error: undefined reference to `cv::imread(cv::String const&, int)' 解決方法

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 )