2014-06-05 209 views
1

當我使用Hello World教程(請參閱下面的鏈接)添加OpenCV時,出現O鏈接器錯誤。我錯過了什麼?將OpenCV添加到iOS應用程序

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) 

回答

2

它看起來像我的項目是不是對C++運行時庫鏈接。要鏈接到運行時庫:

  1. 轉到項目的「構建階段」選項卡。

  2. 選擇「與庫鏈接二進制文件」部分。

  3. 單擊部分底部的「+」按鈕。

  4. 從出現的列表中,選擇OpenCV 2.4.3的「libC++。dylib」或OpenCV 2.4.2及之前的「libstdC++。dylib」。

  5. 重建,一切都應該工作。

相關問題