【问题标题】:OpenCV Framework: symbol(s) not found for architecture armv7OpenCV 框架:未找到架构 armv7 的符号
【发布时间】:2014-01-20 11:22:20
【问题描述】:

我从 OpenCV 获得了 precompiled opencv2.framework,并将其添加到我的项目中。但是尝试编译项目会出现以下错误:

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 Active Architectures Only 设置为No,但它仍然会发生。我需要做什么才能让 OpenCV 正常工作?我正在使用 XCode 5,针对 iOS7。

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

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

无论我是iOS6还是7作为部署目标都是一样的。

【问题讨论】:

  • 您找到解决方案了吗?

标签: xcode opencv


【解决方案1】:

你应该检查两件事:

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

  2. ALAssetsLibrary 在AssetsLibrary.framework 中定义,请将其添加到您项目的Link Binary With Libraries 步骤中。

【讨论】:

  • 我错过了 AssetsLibrary。谢谢!
猜你喜欢
  • 2016-04-29
  • 1970-01-01
  • 2021-06-28
  • 1970-01-01
  • 2015-03-22
  • 2014-02-22
  • 2020-09-09
  • 2011-09-19
相关资源
最近更新 更多