1.报错形式如下
Undefined symbols for architecture x86_64: "std::__1::__vector_base_common::__throw_length_error() const", referenced from: cv::SparseMat::resizeHashTab(unsigned long) in opencv2(matrix.o) std::__1::vector>::__append(unsigned long) in opencv2(matrix.o) std::__1::vector>::__append(unsigned long) in opencv2(matrix.o) std::__1::enable_if<(__is_forward_iterator::value) && (is_constructible::reference>::value), void>::type std::__1::vector>::assign(cv::cuda::GpuMat*, cv::cuda::GpuMat*) in opencv2(matrix.o) std::__1::vector>, std::__1::allocator> > >::__append(unsigned long) in opencv2(matrix.o) std::__1::vector>, std::__1::allocator> > >::__swap_out_circular_buffer(std::__1::__split_buffer>, std::__1::allocator> >&>&) in opencv2(matrix.o) std::__1::vector>::__append(unsigned long) in opencv2(matrix.o) ... "std::__1::__basic_string_common::__throw_length_error() const", referenced from: std::__1::basic_stringbuf, std::__1::allocator>::str() const in opencv2(ocl.o) "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from: std::__1::basic_ostream>& std::__1::__put_character_sequence>(std::__1::basic_ostream>&, char const*, unsigned long) in opencv2(ocl.o) "std::__1::ios_base::getloc() const", referenced from: std::__1::basic_ostream>& std::__1::__put_character_sequence>(std::__1::basic_ostream>&, char const*, unsigned long) in opencv2(ocl.o) "std::__1::basic_string, std::__1::allocator>::resize(unsigned long, char)", referenced from: std::__1::basic_stringbuf, std::__1::allocator>::str(std::__1::basic_string, std::__1::allocator> const&) in opencv2(ocl.o) std::__1::basic_stringbuf, std::__1::allocator>::overflow(int) in opencv2(ocl.o) "std::__1::basic_string, std::__1::allocator>::push_back(char)", referenced from: std::__1::basic_stringbuf, std::__1::allocator>::overflow(int) in opencv2(ocl.o) "std::__1::basic_string, std::__1::allocator>::~basic_string()", referenced from: cv::ocl::kernelToStr(cv::_InputArray const&, int, char const*) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) ... "std::__1::basic_string, std::__1::allocator>::operator=(std::__1::basic_string, std::__1::allocator> const&)", referenced from: std::__1::basic_stringbuf, std::__1::allocator>::str(std::__1::basic_string, std::__1::allocator> const&) in opencv2(ocl.o) "std::__1::basic_ostream>::sentry::sentry(std::__1::basic_ostream>&)", referenced from: std::__1::basic_ostream>& std::__1::__put_character_sequence>(std::__1::basic_ostream>&, char const*, unsigned long) in opencv2(ocl.o) "std::__1::basic_ostream>::sentry::~sentry()", referenced from: std::__1::basic_ostream>& std::__1::__put_character_sequence>(std::__1::basic_ostream>&, char const*, unsigned long) in opencv2(ocl.o) "std::__1::basic_ostream>::~basic_ostream()", referenced from: construction vtable for std::__1::basic_ostream>-in-std::__1::basic_ostringstream, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_ostream>::~basic_ostream()", referenced from: construction vtable for std::__1::basic_ostream>-in-std::__1::basic_ostringstream, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_ostream>::~basic_ostream()", referenced from: std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) ... "std::__1::basic_ostream>::operator<<(double)", referenced from: std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) "std::__1::basic_ostream>::operator<<(float)", referenced from: std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) "std::__1::basic_ostream>::operator<<(int)", referenced from: std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) ... "std::__1::basic_ostream>::operator<<(short)", referenced from: std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) "std::__1::basic_ostream>::operator<<(unsigned short)", referenced from: std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) "std::__1::basic_streambuf>::sync()", referenced from: vtable for std::__1::basic_stringbuf, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_streambuf>::imbue(std::__1::locale const&)", referenced from: vtable for std::__1::basic_stringbuf, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_streambuf>::uflow()", referenced from: vtable for std::__1::basic_stringbuf, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_streambuf>::setbuf(char*, long)", referenced from: vtable for std::__1::basic_stringbuf, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_streambuf>::xsgetn(char*, long)", referenced from: vtable for std::__1::basic_stringbuf, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_streambuf>::xsputn(char const*, long)", referenced from: vtable for std::__1::basic_stringbuf, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_streambuf>::showmanyc()", referenced from: vtable for std::__1::basic_stringbuf, std::__1::allocator> in opencv2(ocl.o) "std::__1::basic_streambuf>::basic_streambuf()", referenced from: std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) ... "std::__1::basic_streambuf>::~basic_streambuf()", referenced from: std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator> cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o) std::__1::basic_string, std::__1::allocator > cv::ocl::kerToStr(cv::Mat const&) in opencv2(ocl.o)ld:
symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation
有这么多的link STL的错误。其实,就是你编译静态库的时候使用不同版本的标准库,C++ Standard Library
类似情况会出现在 c++ 混编的情况下,如下设置可消除报错