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`
赞
踩
如果直接写 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
但是如下就不会错了。。。。
add the library path
then use the command
|
或者这样:
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}
)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。