当前位置:   article > 正文

OPENCV 测试Mat_undefined reference to `cv::mat::create(int, int c

undefined reference to `cv::mat::create(int, int const*, int)

如果直接写 g++ -o test test.cpp 这样会出错。

错误提示如下:

Mat_test.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x2b): undefined reference to `cv::fastFree(void*)'
/tmp/ccudVHxi.o: In function `cv::Mat::create(int, int, int)':
Mat_test.cpp:(.text._ZN2cv3Mat6createEiii[cv::Mat::create(int, int, int)]+0x81): undefined reference to `cv::Mat::create(int, int const*, int)'
/tmp/ccudVHxi.o: In function `cv::Mat::release()':
Mat_test.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x3b): undefined reference to `cv::Mat::deallocate()'
collect2: ld returned 1 exit status


但是如下就不会错了。。。。


2
down vote accepted

add the library path

export LD_LIBRARY_PATH=$LD_LIBARARY_PATH:/usr/local/lib

then use the command

g++ -o sample sample.cpp `pkg-config --cflags --libs opencv` 

或者这样:

                It looks like the pkg-config program is assuming that the library path for opencv libs in in the default path, and it is not.
try adding the -L option to the gcc line. (-L{path to opencv libs})

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/300507
推荐阅读
相关标签
  

闽ICP备14008679号