为Xamarin iOS项目创建Card.IO绑定的麻烦

Ste*_*rov 1 xamarin.ios xamarin card.io

以前我手动制作了Card.IO绑定.它正在编译,使用它的项目也是如此,但它会经常崩溃.

现在我尝试从头开始使用ObjectiveSharpie重新创建绑定.绑定项目编译,但当我从另一个项目引用它时,我得到如下所示的编译器错误.

它将AVFoundation框架项显示为"未定义的符号......",因此在Xamarin的IOS Build选项中,我有"-cxx"选项.我尝试了各种方法组合来向项目添加框架: - 在CardIO绑定项目中修改[assembly:LinkWith(...,Frameworks ="...")].这导致我的主项目中无法识别的CardIO命名空间 - 添加了-gcc_flags"-framework ...".这导致来自编译器的"找不到框架"消息我最终通过包含a来解析AVFoundation using AVFoundation,然后在其类中请求类型名称,因此链接器不会优化它 - 我书中的丑陋黑客.

在下面的错误中,看起来有更多的框架丢失,除此之外,我相信std::...应该通过使用"-cxx"参数来解决这些问题.

我没有想法如何使这个绑定编译和正常工作.

Undefined symbols for architecture armv7:
  "_AudioServicesPlayAlertSound", referenced from:
      -[CardIOCameraViewController vibrate] in libCardIO.a(CardIOCameraViewController.o)
  "_CMGetAttachment", referenced from:
      -[CardIOVideoStream captureOutput:didOutputSampleBuffer:fromConnection:] in libCardIO.a(CardIOVideoStream.o)
  "_CMSampleBufferGetImageBuffer", referenced from:
      -[CardIOVideoFrame process] in libCardIO.a(CardIOVideoFrame.o)
  "_CVPixelBufferGetBaseAddressOfPlane", referenced from:
      +[CardIOIplImage imageFromYCbCrBuffer:plane:] in libCardIO.a(CardIOIplImage.o)
  "_CVPixelBufferGetBytesPerRowOfPlane", referenced from:
      +[CardIOIplImage imageFromYCbCrBuffer:plane:] in libCardIO.a(CardIOIplImage.o)
  "_CVPixelBufferGetHeightOfPlane", referenced from:
      +[CardIOIplImage imageFromYCbCrBuffer:plane:] in libCardIO.a(CardIOIplImage.o)
  "_CVPixelBufferGetWidthOfPlane", referenced from:
      +[CardIOIplImage imageFromYCbCrBuffer:plane:] in libCardIO.a(CardIOIplImage.o)
  "_CVPixelBufferLockBaseAddress", referenced from:
      -[CardIOVideoFrame process] in libCardIO.a(CardIOVideoFrame.o)
  "_CVPixelBufferUnlockBaseAddress", referenced from:
      -[CardIOVideoFrame process] in libCardIO.a(CardIOVideoFrame.o)
  "_OBJC_CLASS_$_EAGLContext", referenced from:
      objc-class-ref in libCardIO.a(CardIOGPURenderer.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::find(char const*, unsigned long, unsigned long) const", referenced from:
      cv::CommandLineParser::CommandLineParser(int, char const* const*, char const*)in libCardIO.a(cmdparser.o)
      (anonymous namespace)::split_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)in libCardIO.a(cmdparser.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::find(char, unsigned long) const", referenced from:
      cv::CommandLineParser::CommandLineParser(int, char const* const*, char const*)in libCardIO.a(cmdparser.o)
      (anonymous namespace)::del_space(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)in libCardIO.a(cmdparser.o)
      cv::CommandLineParser::printParams()      in libCardIO.a(cmdparser.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::rfind(char, unsigned long) const", referenced from:
      (anonymous namespace)::del_space(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)in libCardIO.a(cmdparser.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
      cv::CommandLineParser::CommandLineParser(int, char const* const*, char const*)in libCardIO.a(cmdparser.o)
      cv::CommandLineParser::printParams()      in libCardIO.a(cmdparser.o)
      bool cv::CommandLineParser::get<bool>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)in libCardIO.a(cmdparser.o)
  "std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
Run Code Online (Sandbox Code Playgroud)

Amp*_*4nd 5

这是一个丑陋的,但最终很容易解决.在目标的构建设置中,在"其他链接器标志"中,我有以下内容:

-lstdc++ -ObjC -lc++
Run Code Online (Sandbox Code Playgroud)

也就是说,libCardIO需要-lstdc ++和-lc ++.

此外,请确保已将"标准库链接"设置为"是".