Question

I am binding an enterprise library to my Monotouch application. It has been an arduous process since Objective Sharpie failed to create the APIs and I had to get creative.
But now, after the compilation finally succeeded I'm faced with a linking problem

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)
      ...

Etc. I tried following the advice in Wrapping a C++ library in Objective-C is not hiding the C++ symbols but it didn't work. Any idea?

Was it helpful?

Solution 2

So what finally solved the problem was linking the standard C++ library using

LinkerFlags="-lsqlite3.0 -lc++"

My entire LinkWith attribute looks like this:

[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++")]

OTHER TIPS

Hello it seems you are compiling using a non c++ compiler, you might want to try setting it inside your iOS project options or inside the LinkWith attribute you should set IsCxx = true on your iOS binding Project

available options on iOS project build options are

  • --compiler:gcc
  • --compiler:g++
  • --compiler:clang
  • --compiler:clang++

you should try either --compiler:g++ or --compiler:clang++

image

Hope this helps

Alex

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top