xcode 編譯opencv ios容易出現的錯誤

OpenSoucre發表於2013-12-31

(1)出現 "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()"之類的錯誤

Undefined symbols for architecture i386:
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from:
      cv::gpu::error(char const*, char const*, int, char const*) in opencv2(gpumat.o)
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<< <std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) in opencv2(gpumat.o)
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<< <std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) in opencv2(gpumat.o)
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(int)", referenced from:
      cv::gpu::error(char const*, char const*, int, char const*) in opencv2(gpumat.o)
  "std::__1::cerr", referenced from:

解決辦法是加入c++庫 ,想專案中加入libc++.dylib

  1. Select your project (the blue file) in your project navigator (Command 1 if it's hidden)
  2. Select your target
  3. Go to Build Phases
  4. Expand "Link Binary With Libraries"
  5. Click the "+"
  6. Type libc++.dylib in the search bar.
  7. Select the libc++.dylib file and press "Add"

(2)出現下面錯誤

"_CVPixelBufferGetBaseAddress", referenced from:
      -[MainViewController imageFromSampleBuffer:] in MainViewController.o
  "_CVPixelBufferUnlockBaseAddress", referenced from:
      -[MainViewController imageFromSampleBuffer:] in MainViewController.o
  "_CVPixelBufferLockBaseAddress", referenced from:
      -[MainViewController imageFromSampleBuffer:] in MainViewController.o
  "_CMSampleBufferGetImageBuffer", referenced from:
      -[MainViewController imageFromSampleBuffer:] in MainViewController.o
  "_CVPixelBufferGetHeight", referenced from:
      -[MainViewController imageFromSampleBuffer:] in MainViewController.o
  "_kCVPixelBufferPixelFormatTypeKey", referenced from:
      _kCVPixelBufferPixelFormatTypeKey$non_lazy_ptr in MainViewController.o
     (maybe you meant: _kCVPixelBufferPixelFormatTypeKey$non_lazy_ptr)
  "_CVPixelBufferGetWidth", referenced from:
      -[MainViewController imageFromSampleBuffer:] in MainViewController.o
  "_CVPixelBufferGetBytesPerRow", referenced from:
      -[MainViewController imageFromSampleBuffer:] in MainViewController.o
  "_CMTimeMake", referenced from:
      -[MainViewController setupCaptureSession] in MainViewController.o
  "_CVPixelBufferGetDataSize", referenced from:
      -[MainViewController imageFromSampleBuffer:] in MainViewController.o

解決方法是新增 AVFoundation , CoreVideo 和 CoreMedia frameworks 

(3)出現下面錯誤assert錯誤時,需要新增AssetsLibrary.framework

相關文章