C++ 关于Xcode中OpenCV的链接错误

C++ 关于Xcode中OpenCV的链接错误,c++,ios,opencv,hyperlink,C++,Ios,Opencv,Hyperlink,我使用的是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 archi

我使用的是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
我将其拖到Frameworks floder,并设置库搜索的正确路径。 但当我编译时,出现了这样的错误:

OpenCV库中使用的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)
“\uuuuuuuucxa\u开始\u捕获”,引用自:
libopencv_core.a(persistence.o)中的icvReadSeq(CvFileStorage*,CvFileNode*)
“std::exception的类型信息”,引用自:
libopencv_core.a(alloc.o)中cv::exception的类型信息
“运算符删除(void*)”,引用自:
libopencv_core.a(alloc.o)中的cv::Exception::~Exception()
“_gzputs”,引用自:
libopencv_core.a(persistence.o)中的icvPuts(CvFileStorage*,char const*)
“std::basic_string::_Rep::_M_destroy(std::allocator const&)”,引用自:
libopencv_core.a(alloc.o)中的cv::OutOfMemoryError(无符号长)
libopencv_core.a(alloc.o)中的cv::Exception::~Exception()
libopencv_core.a(alloc.o)中的cv::Exception::~Exception()
_libopencv_core.a(array.o)中的CVCreateMathHeader
_libopencv_core.a(array.o)中的cvGetImageCOI
_libopencv_core.a(array.o)中的cvSetImageCOI
_libopencv_core.a(array.o)中的cvGetSize
...
“std::basic_string::assign(std::basic_string const&)”,引用自:
libopencv_core.a(alloc.o)中的cv::OutOfMemoryError(无符号长)
libopencv_core.a(array.o)中的异常(int,std::basic_string const&,std::basic_string const&,std::basic_string const&,int)
_libopencv_core.a(system.o)中的cvRegisterModule
“\uuuuuuuucxa\u throw”,引用自:
libopencv_core.a(system.o)中的cv::error(cv::Exception const&)
“\uuuuuuuucxa\u end\u catch”,引用自:
libopencv_core.a(persistence.o)中的icvReadSeq(CvFileStorage*,CvFileNode*)
“_CVTColor”,引用自:
-[cviosViewController.o中的[cviosViewController CreateIplImageFromUIImage:]
“vtable for std::exception”,引用自:
libopencv_core.a(array.o)中的异常(int,std::basic_string const&,std::basic_string const&,std::basic_string const&,int)
libopencv_core.a(system.o)中的cv::error(cv::Exception const&)
“运算符新[](无符号长)”引用自:
libopencv_core.a(convert.o)中的cv::mixChannels(cv::Mat const*、无符号long、cv::Mat*、无符号long、int const*、无符号long)
“std::basic_string::basic_string(std::basic_string const&)”,引用自:
libopencv_core.a(alloc.o)中的cv::OutOfMemoryError(无符号长)
libopencv_core.a(array.o)中的异常(int,std::basic_string const&,std::basic_string const&,std::basic_string const&,int)
libopencv_core.a(system.o)中的cv::error(cv::Exception const&)
_libopencv_core.a(system.o)中的cvRegisterModule
“vtable for uuu cxxabiv1::uu si_class_type_info”,引用自:
libopencv_core.a(alloc.o)中cv::exception的类型信息
“std::terminate()”,引用自:
libopencv_core.a(system.o)中的cv::error(cv::Exception const&)
“\uuuuuuuucxa\u分配\u异常”,引用自:
libopencv_core.a(system.o)中的cv::error(cv::Exception const&)
“uuuuuuugxx_个性_sj0”,引用自:
libopencv_core.a(alloc.o)中的cv::OutOfMemoryError(无符号长)
_libopencv_core.a(array.o)中的CVCreateMathHeader
_libopencv_core.a(array.o)中的cvGetImageCOI
_libopencv_core.a(array.o)中的cvSetImageCOI
_libopencv_core.a(array.o)中的cvGetSize
_libopencv_core.a(array.o)中的cvGetDims
_libopencv_core.a(array.o)中的cvGetElemType
...
“std::basic_string::basic_string(char const*,std::allocator const&)”,引用自:
libopencv_core.a(alloc.o)中的cv::OutOfMemoryError(无符号长)
_libopencv_core.a(array.o)中的CVCreateMathHeader
_libopencv_core.a(array.o)中的cvGetImageCOI
_libopencv_core.a(array.o)中的cvSetImageCOI
_libopencv_core.a(array.o)中的cvGetSize
_libopencv_core.a(array.o)中的cvGetDims
_libopencv_core.a(array.o)中的cvGetElemType
...
“运算符删除[](void*)”,引用自:
libopencv_core.a(convert.o)中的cv::mixChannels(cv::Mat const*、无符号long、cv::Mat*、无符号long、int const*、无符号long)
“std::basic_string::_Rep::_S_empty_Rep_storage”,引用自:
libopencv_core.a(alloc.o)中的cv::OutOfMemoryError(无符号长)
libopencv_core.a(alloc.o)中的cv::Exception::~Exception()
libopencv_core.a(alloc.o)中的cv::Exception::~Exception()
_libopencv_core.a(array.o)中的CVCreateMathHeader
_libopencv_core.a(array.o)中的cvGetImageCOI
_libopencv_core.a(array.o)中的cvSetImageCOI
_libopencv_core.a(array.o)中的cvGetSize
...
“std::exception::~exception()”,引用自:
libopencv_core.a(alloc.o)中的cv::OutOfMemoryError(无符号长)
libopencv_core.a(alloc.o)中的cv::Exception::~Exception()
libopencv_core.a(alloc.o)中的cv::Exception::~Exception()
libopencv_core.a(array.o)中的异常(int,std::basic_string const&,std::basic_string const&,std::basic_string const&,int)
libopencv_core.a(system.o)中的cv::error(cv::Exception const&)
_libopencv_core.a(system.o)中的cvRegisterModule
ld:未找到架构armv7的符号 collect2:ld返回了1个退出状态

顺便说一句:当我将文件名设置为.mm时,链接器会报告内部编译器错误。总线错误。

我得到了答案

OpenCV中的MIN宏与Xcode中预定义的MIN冲突

将.m文件重命名为.mm,并将all MIN函数更改为新名称,例如OpenCV头文件中的CV_MIN


检查

Bing,关于OpenCV的最小(和最大)宏,您是正确的。我必须重新命名它们,可能是因为v2.0:)

但是,没有必要将所有的.m文件重命名为.mm文件,因为Xcode在默认情况下会对它们进行不同的处理——即Objec