xcode - OpenCV 框架 : symbol(s) not found for architecture armv7

标签 xcode opencv

我有 precompiled opencv2.framework来自 OpenCV,我已将其添加到我的项目中。但是尝试编译项目会出现如下错误:

Undefined symbols for architecture armv7:
  "std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
      std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >::__append(unsigned long) in opencv2(matrix.o)
      std::__1::vector<cv::Vec<int, 128>, std::__1::allocator<cv::Vec<int, 128> > >::__append(unsigned long) in opencv2(matrix.o)
      std::__1::vector<cv::Vec<int, 64>, std::__1::allocator<cv::Vec<int, 64> > >::__append(unsigned long) in opencv2(matrix.o)
      std::__1::vector<cv::Vec<int, 32>, std::__1::allocator<cv::Vec<int, 32> > >::__append(unsigned long) in opencv2(matrix.o)
      std::__1::vector<cv::Vec<int, 16>, std::__1::allocator<cv::Vec<int, 16> > >::__append(unsigned long) in opencv2(matrix.o)
      std::__1::vector<cv::Vec<int, 12>, std::__1::allocator<cv::Vec<int, 12> > >::__append(unsigned long) in opencv2(matrix.o)
      std::__1::vector<cv::Vec<int, 9>, std::__1::allocator<cv::Vec<int, 9> > >::__append(unsigned long) in opencv2(matrix.o)
      ...
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      cv::Exception::Exception(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) in opencv2(system.o)
      cv::error(cv::Exception const&) in opencv2(system.o)
      _cvRegisterModule in opencv2(system.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      cv::Exception::formatMessage() in opencv2(system.o)
  "_OBJC_CLASS_$_ALAssetsLibrary", referenced from:
      objc-class-ref in opencv2(cap_ios_video_camera.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long)", referenced from:
      cv::sum(cv::_InputArray const&) in opencv2(stat.o)
      cv::countNonZero(cv::_InputArray const&) in opencv2(stat.o)
      cv::mean(cv::_InputArray const&, cv::_InputArray const&) in opencv2(stat.o)
      cv::meanStdDev(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_InputArray const&) in opencv2(stat.o)
      cv::minMaxIdx(cv::_InputArray const&, double*, double*, int*, int*, cv::_InputArray const&) in opencv2(stat.o)
      cv::minMaxLoc(cv::_InputArray const&, double*, double*, cv::Point_<int>*, cv::Point_<int>*, cv::_InputArray const&) in opencv2(stat.o)
      cv::norm(cv::_InputArray const&, int, cv::_InputArray const&) in opencv2(stat.o)
      ...
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
      cv::sum(cv::_InputArray const&) in opencv2(stat.o)
      cv::countNonZero(cv::_InputArray const&) in opencv2(stat.o)
      cv::mean(cv::_InputArray const&, cv::_InputArray const&) in opencv2(stat.o)
      cv::meanStdDev(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_InputArray const&) in opencv2(stat.o)
      cv::minMaxIdx(cv::_InputArray const&, double*, double*, int*, int*, cv::_InputArray const&) in opencv2(stat.o)
      cv::minMaxLoc(cv::_InputArray const&, double*, double*, cv::Point_<int>*, cv::Point_<int>*, cv::_InputArray const&) in opencv2(stat.o)
      cv::norm(cv::_InputArray const&, int, cv::_InputArray const&) in opencv2(stat.o)
      ...
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我在我的build设置中将 Build Active Architectures Only 设置为 No,但它仍然发生。我需要做什么才能让 OpenCV 正常工作?我正在使用针对 iOS7 的 XCode 5。

我已经added -lstdc++ to linker flags and switch the C++ compiler to libstdc++, as-per this answer .

我也尝试过从源代码编译 OpenCV,但会产生同样的错误。

不管部署目标是iOS6还是7,都是一样的。

最佳答案

你应该检查两件事:

  1. 您正在尝试使用 OpenCV 的 C++ 部分,但 Xcode/clang 非常直白。如果您链接的文件是 .m它会将其视为 Objective-C。相反,我们希望通过将扩展名重命名为 .mm 来将其视为 Objective-C++ 文件。或者通过在右侧栏中调出文件的属性并选择 Objective-C++ Source对于类型

  2. ALAssetsLibraryAssetsLibrary.framework 中定义,请将它添加到您的项目的Link Binary With Libraries 步骤中。

关于xcode - OpenCV 框架 : symbol(s) not found for architecture armv7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21232694/

相关文章:

swift - <未知> :0: error: type 'Key' constrained to non-protocol type 'String'

ios - 使用 Storyboard 设计 ViewController

ios - Kingfisher nil 在展开可选值时

python - CV2 : Import Error in Python OpenCV

c++ - 使用 Cmake 为 Visual Studio 2015 构建 OpenCV 3.0.0 的 DLL

ios - 滚动表格 View 后点击选择行时如何修复崩溃?

ios - Facebook UIActivityViewController 缺少取消和发布按钮

c++ - 我如何使用 opencv 取 100 张图像的平均值?

c - ‘true’ 在 opencv 中未声明(首次在此函数中使用)

visual-studio-2010 - 使用opencv进行阈值化