1

以前我手动进行了 Card.IO 绑定。它正在编译,使用它的项目也在编译,但它会经常崩溃。

现在我正在尝试使用 ObjectiveSharpie 从头开始​​重新创建绑定。绑定项目可以编译,但是当我从另一个项目中引用它时,会出现如下所示的编译器错误。

它将 AVFoundation 框架项目显示为“未定义的符号...”,因此在 Xamarin 的 IOS 构建选项下,我有“-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:
4

2 回答 2

5

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

-lstdc++ -ObjC -lc++

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

此外,请确保您已将“与标准库的链接”设置为“是”。

于 2013-11-01T21:25:33.653 回答
4

经过大量的猜测、试错和搜索输出中的每个特定错误后,我想出了一个可行的解决方案,将此属性添加到绑定项目中的 .linkwith.cs 文件中:

[assembly: LinkWith ("libCardIO.a", IsCxx=true, LinkTarget= LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, ForceLoad = true
                     ,Frameworks = "AVFoundation AudioToolbox CoreMedia CoreVideo OpenGLES MobileCoreServices"
                     ,LinkerFlags = "-ObjC -lc++")]

我曾假设添加

-cxx -gcc_flags "-lstdc++"

到主项目的 iOS 构建应该做同样的事情,但事实并非如此,无论有没有这些额外的编译器参数,绑定都没有构建。

如果您需要绑定项目的副本,请询问。

于 2013-08-07T13:53:55.237 回答