OPENCV 测试Mat

来源:互联网 发布:excel每隔几行取数据 编辑:程序博客网 时间:2024/06/05 07:33

如果直接写 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 voteaccepted

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})

0 0
原创粉丝点击