原地址:
http://www.it1352.com/474798.html
错误提示如下:
Undefined symbols for architecture x86_64:
"cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
_main in test-41a30e.o
"cv::namedWindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
_main in test-41a30e.o
"cv::destroyWindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in test-41a30e.o
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in test-41a30e.o
"cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
_main in test-41a30e.o
"cv::imshow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in test-41a30e.o
"cv::waitKey(int)", referenced from:
_main in test-41a30e.o
"cv::fastFree(void*)", referenced from:
cv::Mat::~Mat() in test-41a30e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解决方法:
brew install pkg-config
brew reinstall opencv
# 加入如下参数编译
g++ $(pkg-config --cflags --libs opencv) test.cpp -o Test
# 运行程序
./Test