Linking failure with a MonoTouch native library bi

2019-05-12 08:41发布

问题:

I am creating native library binding for the Wikitude SDK.

The MonoTouch app fails linking:

Undefined symbols for architecture armv7:
"std::__1::basic_string, std::__1::allocator >::find_last_of(char const*, unsigned long, unsigned long) const", referenced from: WtUnzip::unzipFileTo(char const*, bool)in WikitudeSDK.a(wtunzip.o) ...

My LinkWith:

[assembly: LinkWith ("WikitudeSDK.a", LinkTarget.ArmV7, Frameworks = "CoreVideo Security SystemConfiguration CoreMedia AVFoundation CFNetwork CoreLocation CoreMotion MediaPlayer OpenGLES QuartzCore CoreGraphics", ForceLoad = true, LinkerFlags = "-lsqlite3.0 -ObjC", IsCxx = true)]

I have to admit that I am new to this MonoTouch/IOS world, by I am trying to get my head out of the water.

What should I do to get my app to link?

回答1:

I just figured that I needed to add libc++ in my LinkWith. My new LinkWith looks like this:

[assembly: LinkWith ("WikitudeSDK.a", LinkTarget.ArmV7, Frameworks = "CoreVideo Security SystemConfiguration CoreMedia AVFoundation CFNetwork CoreLocation CoreMotion MediaPlayer OpenGLES QuartzCore CoreGraphics", ForceLoad = true, LinkerFlags = "-lsqlite3.0 -ObjC -lc++", IsCxx = true)]

Hopefully that can eventually help others.



回答2:

I was dealing with an issue where the linking step was failing with "Native linking failed, undefined symbol: std::string::find_last_of(char const*, unsigned long, unsigned long)..."

It turned out the iOS Deployment Target for the app was apparently not matched with the original native library. By matching those up (by comparing against a working "consumer" of the same binding library) I was able to get past the errors.