以前我手动制作过Card.IO绑定。它正在编译,使用它的项目也是如此,但它会经常崩溃。
现在我正尝试从头开始使用ObjectiveSharpie重新创建绑定。绑定项目编译但是当我从另一个项目引用它时,我得到如下所示的编译器错误。
它将AVFoundation框架项显示为“未定义的符号......”,因此在Xamarin中的IOS Build选项下,我有“-cxx”选项。我尝试了各种方法组合来为项目添加框架:
- 在CardIO绑定项目中修改[assembly:LinkWith(...,Frameworks =“...”)]。这导致我的主项目中无法识别的CardIO命名空间
- 添加-gcc_flags“-framework ...”。这导致编译器发现“找不到框架”消息
我最后通过包含一个using AVFoundation
来解析AVFoundation,然后在其类中请求类型名称为1,这样链接器就不会对它进行优化 - 在我的书中难以理解。
在下面的错误中,似乎缺少更多的框架,我相信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:
答案 0 :(得分:5)
这是一个丑陋的,但最终很容易解决。在目标的构建设置中,在“其他链接器标志”中,我有以下内容:
-lstdc++ -ObjC -lc++
也就是说,libCardIO需要-lstdc ++和-lc ++。
另外,请确保已将“标准库链接”设置为“是”。
答案 1 :(得分: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构建应该做同样的事情,但事实并非如此,无论是否有这些额外的编译器参数,绑定都没有构建。
如果您需要绑定项目的副本,请询问。