方法1
原文链接:https://blog.csdn.net/WhiteLiu/article/details/72901520
编译时出现下列错误:
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(目录opencv3.4.2\opencv\sources)加入安装OpenCV的版本号:
将
find_package( OpenCV REQUIRED )
更改为
find_package( OpenCV 3 REQUIRED ) 。
方法2
修改QT项目内的.pro文件中的静态库(libopencv_*.dll.a)的链接路径,由相对路径改为绝对路径,路径中不能有中文以及特殊字符。可以选择如下方式一次性添加所有的库:
LIBS += -L E:\QTProgram\testOpencv342\lib\libopencv_*.dll.a
也可以逐个添加
LIBS += E:\QTProgram\testOpencv342\lib\libopencv_calib3d342.dll.a标签:const,undefined,reference,int,deallocate,cv,String From: https://www.cnblogs.com/rainbow70626/p/17652952.html