如何将C ++标准库链接到Monotouch应用程序

时间:2013-08-29 12:25:35

标签: c++ binding xamarin.ios standard-library

我正在将企业库绑定到我的Monotouch应用程序。 由于Objective Sharpie未能创建API而且我必须具有创造性,这是一个艰难的过程 但是现在,在编译终于成功后,我面临着一个链接问题

Undefined symbols for architecture armv7:
  "std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
      __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initIPcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeES9_S9_ in libWeANDSFLibrary.a(WfStringBody.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::resize(unsigned long, char)", referenced from:
      std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::overflow(int)in libWeANDSFLibrary.a(WfStringBody.o)
      std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::str(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)in libWeANDSFLibrary.a(WfStringBody.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::push_back(char)", referenced from:
      std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::overflow(int)in libWeANDSFLibrary.a(WfStringBody.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
      wflang::CWfStringBody::Float64ToArray(double, unsigned short*)in libWeANDSFLibrary.a(WfStringBody.o)
      std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_ostringstream()in libWeANDSFLibrary.a(WfStringBody.o)
      std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_ostringstream()in libWeANDSFLibrary.a(WfStringBody.o)
      virtual thunk to std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_ostringstream()in libWeANDSFLibrary.a(WfStringBody.o)
      virtual thunk to std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_ostringstream()in libWeANDSFLibrary.a(WfStringBody.o)
      std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringbuf()in libWeANDSFLibrary.a(WfStringBody.o)
      std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringbuf()in libWeANDSFLibrary.a(WfStringBody.o)
      ...

等。 我尝试按照Wrapping a C++ library in Objective-C is not hiding the C++ symbols中的建议,但它没有用。 有什么想法吗?

2 个答案:

答案 0 :(得分:4)

您好,似乎您正在使用非c ++编译器进行编译,您可能想尝试在 iOS项目选项中设置它,或者在LinkWith attribute内设置IsCxx = true iOS绑定项目

iOS项目构建选项上的

可用选项

  • - 编译器:GCC
  • - 编译器:克++
  • - 编译器:铛
  • - 编译器:铛++

您应该尝试--compiler:g++--compiler:clang++

image

希望这有帮助

亚历

答案 1 :(得分:2)

所以最终解决问题的是使用

链接标准C ++库
  

LinkerFlags =“ - lsqlite3.0 -lc ++”

我的整个LinkWith属性如下所示:

  

[assembly:LinkWith(“libMyLibrary.a”,LinkTarget = LinkTarget.ArmV6 | LinkTarget.ArmV7 | LinkTarget.Simulator,SmartLink = true,ForceLoad = true,IsCxx = true,Frameworks =“SystemConfiguration CoreLocation CoreTelephony MobileCoreServices MessageUI”, LinkerFlags =“ - lsqlite3.0 -lc ++”)]