【问题标题】:Adding OpenCV to iOS application将 OpenCV 添加到 iOS 应用程序
【发布时间】:2014-06-05 01:53:01
【问题描述】:

当我使用 Hello World 教程(请参阅下面的链接)添加 OpenCV 时,我收到 O Linker 错误。我错过了什么吗?

http://docs.opencv.org/doc/tutorials/ios/hello/hello.html#opencvioshelloworld

Undefined symbols for architecture armv7:
  "std::string::operator=(char const*)", referenced from:
      cv::BmpDecoder::BmpDecoder() in opencv2(grfmt_bmp.o)
      cv::BmpEncoder::BmpEncoder() in opencv2(grfmt_bmp.o)
      cv::PxMEncoder::PxMEncoder() in opencv2(grfmt_pxm.o)
      cv::TiffEncoder::TiffEncoder() in opencv2(grfmt_tiff.o)
      cv::SunRasterDecoder::SunRasterDecoder() in opencv2(grfmt_sunras.o)
      cv::SunRasterEncoder::SunRasterEncoder() in opencv2(grfmt_sunras.o)
  "___cxa_pure_virtual", referenced from:
      vtable for cv::MatOp in opencv2(matop.o)
      vtable for cv::BaseImageDecoder in opencv2(grfmt_base.o)
      vtable for cv::BaseImageEncoder in opencv2(grfmt_base.o)
  "vtable for std::exception", referenced from:
      std::exception::exception() in opencv2(system.o)
      std::exception::exception(std::exception const&) in opencv2(system.o)
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "___cxa_allocate_exception", referenced from:
      cv::error(cv::Exception const&) in opencv2(system.o)
      cv::PxMDecoder::readHeader() in opencv2(grfmt_pxm.o)
      cv::RBaseStream::readBlock() in opencv2(bitstrm.o)
  "std::string::operator[](unsigned long) const", referenced from:
      cv::PxMDecoder::checkSignature(std::string const&) const in opencv2(grfmt_pxm.o)
  "std::string::size() const", referenced from:
      cv::Exception::formatMessage() in opencv2(system.o)
      cv::error(cv::Exception const&) in opencv2(system.o)
      cv::PxMDecoder::checkSignature(std::string const&) const in opencv2(grfmt_pxm.o)
      cv::BaseImageDecoder::signatureLength() const in opencv2(grfmt_base.o)
      cv::BaseImageDecoder::checkSignature(std::string const&) const in opencv2(grfmt_base.o)

【问题讨论】:

    标签: c++ ios objective-c opencv


    【解决方案1】:

    看起来我的项目没有链接到 C++ 运行时库。链接运行时库:

    1. 转到项目的“构建阶段”选项卡。

    2. 选择“将二进制文件与库链接”部分。

    3. 点击该部分底部的“+”按钮。

    4. 从出现的列表中,为 OpenCV 2.4.3 选择“libc++.dylib”,或为 OpenCV 2.4.2 及更早版本选择“libstdc++.dylib”。

    5. 重新编译,一切正常。

    【讨论】:

      猜你喜欢
      • 2012-05-11
      • 2013-02-16
      • 1970-01-01
      • 2019-04-02
      • 2018-05-10
      • 2012-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多