关于Xcode中OpenCV的链接错误

Bin*_*Hsu 2 c++ opencv hyperlink ios

我正在使用XCode4和OpenCV 2.3.我编译了一份OpenCV.这是.a的信息:

libopencv_core.a: Mach-O universal binary with 3 architectures
libopencv_core.a (for architecture armv7):  current ar archive random library
libopencv_core.a (for architecture armv6):  current ar archive random library
libopencv_core.a (for architecture i386):   current ar archive random library
Run Code Online (Sandbox Code Playgroud)

我将它拖到Frameworks floder中,并设置库搜索的正确路径.但是当我编译时,它发生了这样的错误:

似乎在OpenCV lib中使用的STL没有链接在.a文件中.怎么解决?

谢谢,低头.

架构armv7的未定义符号:

"___cxa_begin_catch", referenced from:
      icvReadSeq(CvFileStorage*, CvFileNode*)       in libopencv_core.a(persistence.o)
  "typeinfo for std::exception", referenced from:
      typeinfo for cv::Exceptionin libopencv_core.a(alloc.o)
  "operator delete(void*)", referenced from:
      cv::Exception::~Exception()in libopencv_core.a(alloc.o)
  "_gzputs", referenced from:
      icvPuts(CvFileStorage*, char const*)in libopencv_core.a(persistence.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&)", referenced from:
      cv::OutOfMemoryError(unsigned long)in libopencv_core.a(alloc.o)
      cv::Exception::~Exception()in libopencv_core.a(alloc.o)
      cv::Exception::~Exception()in libopencv_core.a(alloc.o)
      _cvCreateMatHeader in libopencv_core.a(array.o)
      _cvGetImageCOI in libopencv_core.a(array.o)
      _cvSetImageCOI in libopencv_core.a(array.o)
      _cvGetSize in libopencv_core.a(array.o)
      ...
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      cv::OutOfMemoryError(unsigned long)in libopencv_core.a(alloc.o)
      cv::Exception::Exception(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)in libopencv_core.a(array.o)
      _cvRegisterModule in libopencv_core.a(system.o)
  "___cxa_throw", referenced from:
      cv::error(cv::Exception const&)in libopencv_core.a(system.o)
  "___cxa_end_catch", referenced from:
      icvReadSeq(CvFileStorage*, CvFileNode*)       in libopencv_core.a(persistence.o)
  "_cvCvtColor", referenced from:
      -[cviosViewController CreateIplImageFromUIImage:] in cviosViewController.o
  "vtable for std::exception", referenced from:
      cv::Exception::Exception(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)in libopencv_core.a(array.o)
      cv::error(cv::Exception const&)in libopencv_core.a(system.o)
  "operator new[](unsigned long)", referenced from:
      cv::mixChannels(cv::Mat const*, unsigned long, cv::Mat*, unsigned long, int const*, unsigned long)in libopencv_core.a(convert.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      cv::OutOfMemoryError(unsigned long)in libopencv_core.a(alloc.o)
      cv::Exception::Exception(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)in libopencv_core.a(array.o)
      cv::error(cv::Exception const&)in libopencv_core.a(system.o)
      _cvRegisterModule in libopencv_core.a(system.o)
  "vtable for __cxxabiv1::__si_class_type_info", referenced from:
      typeinfo for cv::Exceptionin libopencv_core.a(alloc.o)
  "std::terminate()", referenced from:
      cv::error(cv::Exception const&)in libopencv_core.a(system.o)
  "___cxa_allocate_exception", referenced from:
      cv::error(cv::Exception const&)in libopencv_core.a(system.o)
  "___gxx_personality_sj0", referenced from:
      cv::OutOfMemoryError(unsigned long)in libopencv_core.a(alloc.o)
      _cvCreateMatHeader in libopencv_core.a(array.o)
      _cvGetImageCOI in libopencv_core.a(array.o)
      _cvSetImageCOI in libopencv_core.a(array.o)
      _cvGetSize in libopencv_core.a(array.o)
      _cvGetDims in libopencv_core.a(array.o)
      _cvGetElemType in libopencv_core.a(array.o)
      ...
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
      cv::OutOfMemoryError(unsigned long)in libopencv_core.a(alloc.o)
      _cvCreateMatHeader in libopencv_core.a(array.o)
      _cvGetImageCOI in libopencv_core.a(array.o)
      _cvSetImageCOI in libopencv_core.a(array.o)
      _cvGetSize in libopencv_core.a(array.o)
      _cvGetDims in libopencv_core.a(array.o)
      _cvGetElemType in libopencv_core.a(array.o)
      ...
  "operator delete[](void*)", referenced from:
      cv::mixChannels(cv::Mat const*, unsigned long, cv::Mat*, unsigned long, int const*, unsigned long)in libopencv_core.a(convert.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage", referenced from:
      cv::OutOfMemoryError(unsigned long)in libopencv_core.a(alloc.o)
      cv::Exception::~Exception()in libopencv_core.a(alloc.o)
      cv::Exception::~Exception()in libopencv_core.a(alloc.o)
      _cvCreateMatHeader in libopencv_core.a(array.o)
      _cvGetImageCOI in libopencv_core.a(array.o)
      _cvSetImageCOI in libopencv_core.a(array.o)
      _cvGetSize in libopencv_core.a(array.o)
      ...
  "std::exception::~exception()", referenced from:
      cv::OutOfMemoryError(unsigned long)in libopencv_core.a(alloc.o)
      cv::Exception::~Exception()in libopencv_core.a(alloc.o)
      cv::Exception::~Exception()in libopencv_core.a(alloc.o)
      cv::Exception::Exception(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)in libopencv_core.a(array.o)
      cv::error(cv::Exception const&)in libopencv_core.a(system.o)
      _cvRegisterModule in libopencv_core.a(system.o)
Run Code Online (Sandbox Code Playgroud)

ld:找不到架构armv7的符号:collect2:ld返回1退出状态

BTW:当我将文件名设置为.mm时,链接器报告内部编译器错误.总线错误.

Vla*_*lad 7

您可以通过"Build Phases - > Link Binary With Libraries"设置与c ++标准库的链接

在此输入图像描述