OpenCV框架:体系结构armv7找不到符号 [英] OpenCV Framework: symbol(s) not found for architecture armv7

查看:127
本文介绍了OpenCV框架:体系结构armv7找不到符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经预编译的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)

在我的构建设置中,我已将仅构建活动体系结构" 设置为,但这仍然会发生.我需要做什么才能使OpenCV正常工作?我正在使用针对iOS7的XCode 5.

根据该答案,我已经-lstdc++添加到链接器标志并将C ++编译器切换到libstdc ++ .

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

无论我将iOS6还是7作为部署目标,都一样.

解决方案

您应检查两件事:

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

  2. ALAssetsLibrary是在AssetsLibrary.framework中定义的,请将其添加到项目的使用库链接二进制文件步骤中.

I've got the precompiled opencv2.framework from OpenCV, and I've added it to my project. However trying to compile the project gives errors like:

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)

I've set Build Active Architectures Only to No in my build settings, but it still happens. What do I need to do to get OpenCV working? I'm using XCode 5, targeting iOS7.

I've already added -lstdc++ to linker flags and switch the C++ compiler to libstdc++, as-per this answer.

I have tried compiling OpenCV from source too but that yields the same error.

It's the same regardless of whether I have iOS6 or 7 as the deployment target.

解决方案

Two things you should check:

  1. You're attempting to use the C++ portions of OpenCV but Xcode/clang are very literal. If the file you're linking with is a .m it'll treat it as an Objective-C. Instead we want to treat it as an Objective-C++ file by either renaming the extension to .mm or by bringing up the file's properties in the right side bar and selecting Objective-C++ Source for the Type.

  2. ALAssetsLibrary is defined in AssetsLibrary.framework, please add it to your Link Binary With Libraries step for your project.

这篇关于OpenCV框架:体系结构armv7找不到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆