OStack程序员社区-中国程序员成长平台

标题: ios - 尝试在已经工作的项目中使用 OpenCV 框架时出现 Apple O-Linker 错误 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 00:49
标题: ios - 尝试在已经工作的项目中使用 OpenCV 框架时出现 Apple O-Linker 错误

我所做的是使用 tutorial 中的一些代码基于openCV框架。 从 EdgeDetectionSample.cpp 文件中,我导入了代码。

Undefined symbols for architecture armv7: "std::__1::basic_string, std::__1::allocator >::basic_string(std::__1::basic_string, std::__1::allocator > const&)", referenced from: cv::Exception::Exception(int, std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, int) in opencv2(system.o) cv::Exception::Exception(cv::Exception const&) in opencv2(system.o) "std::__1::basic_string, std::__1::allocator >::~basic_string()", referenced from: cv::Mat::create(int, int const*, int) in opencv2(matrix.o) __ZN2cvL7setSizeERNS_3MatEiPKiPKmb in opencv2(matrix.o) cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&) in opencv2(matrix.o) cv::Mat::Mat(cv::Mat const&, cv::Range const*) in opencv2(matrix.o) cv::Mat::diag(int) const in opencv2(matrix.o) cv::Mat::Mat(_IplImage const*, bool) in opencv2(matrix.o) cv::Mat::reserve(unsigned long) in opencv2(matrix.o) ... "std::__1::basic_string, std::__1::allocator >::__init(char const*, unsigned long)", referenced from: cv::Mat::create(int, int const*, int) in opencv2(matrix.o) __ZN2cvL7setSizeERNS_3MatEiPKiPKmb in opencv2(matrix.o) cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&) in opencv2(matrix.o) cv::Mat::Mat(cv::Mat const&, cv::Range const*) in opencv2(matrix.o) cv::Mat::diag(int) const in opencv2(matrix.o) cv::Mat::Mat(_IplImage const*, bool) in opencv2(matrix.o) cv::Mat::reserve(unsigned long) in opencv2(matrix.o) ... "std::_1::_vector_base_common::__throw_length_error() const", referenced from: std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) std::_1::vector, std::__1::allocator > >::_append(unsigned long) in opencv2(matrix.o) ... "std::__1::basic_string, std::__1::allocator >:perator=(std::__1::basic_string, std::__1::allocator > const&)", referenced from: cv::Exception::formatMessage() in opencv2(system.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

请帮我解决这个问题。我无法阅读这些错误。



Best Answer-推荐答案


您的项目链接到 libstd++(GNU C++ 标准库),但最新的 OpenCV 链接到 libc++(支持 C++ 11 的 LLVM C++ 标准库),所以您有两种方法可以解决这个问题:

  1. 将您的项目与 libc++ 相关联
  2. 使用 libstd++ 重建 OpenCV。

要将您的项目与 libc++ 链接,请转到 -> build设置 -> 找到“C++ 标准库”行并在那里选择 libc++。

关于ios - 尝试在已经工作的项目中使用 OpenCV 框架时出现 Apple O-Linker 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14701414/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4