undefined reference to `cv::imread(cv::String const&, int)'

5 篇文章 3 订阅
4 篇文章 0 订阅

记录一次很诡异的错误,由于粗心,在使用opencv中的cv::imread函数的时候,在CMakeLists.txt中忘记添加库连接

target_link_libraries( opencv_test ${OpenCV_LIBS} )

编译出错

CMakeFiles/opencv_test.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x53): undefined reference to `cv::imread(cv::String const&, int)'
main.cpp:(.text+0xa5): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
main.cpp:(.text+0xcd): undefined reference to `cv::waitKey(int)'
CMakeFiles/opencv_test.dir/main.cpp.o: In function `cv::String::String(char const*)':
main.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x54): undefined reference to `cv::String::allocate(unsigned long)'
CMakeFiles/opencv_test.dir/main.cpp.o: In function `cv::String::~String()':
main.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/opencv_test.dir/main.cpp.o: In function `cv::Mat::~Mat()':
main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
CMakeFiles/opencv_test.dir/main.cpp.o: In function `cv::Mat::release()':
main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/opencv_test.dir/build.make:83: recipe for target 'opencv_test' failed
make[2]: *** [opencv_test] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/opencv_test.dir/all' failed
make[1]: *** [CMakeFiles/opencv_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值