How to add the libsqlite3.0.dylib in MonoTouch Binding Project?

binding, dylib, xamarin.ios

Solution

Try adding `-lsqlite3.0` to your `LinkerFlags` for your binding to instruct the (native) linker to load the SQLite library (and symbols).

[assembly: LinkWith ("your_lib.a", LinkTarget.ArmV7, ForceLoad = true, LinkerFlags="-lsqlite3.0")]

Problem

I want to integrate the Aviary SDK Objective-C library into Monotouch project. I use 'Monotouch Binding Project' template for this. So I have created the API Definition file and define LinkWith Attributes. ``` [assembly: LinkWith ("libAviarySDK.a", LinkTarget = LinkTarget.ArmV6 | LinkTarget.ArmV7 | LinkTarget.Simulator, ForceLoad = true, IsCxx = true, Frameworks="CoreGraphics QuartzCore Accelerate StoreKit CoreData", LinkerFlags="-ObjC -all_load -fobjc-arc")] ``` It requires the following libraries: - Foundation.framework - UIKit.framework - CoreGraphics.framework - QuartzCore.framework - Accelerate.framework - StoreKit.framework - libz.1.2.5.dylib - libsqlite3.0.dylib - CoreData.framework All these frameworks are linked without problems except the libsqlite3.0.dylib The problem that I am encountering, though, is that the library depends on libsqlite3.0.dylib and I do not know how to include these frameworks in my MonoTouch application. In a result - compiler returns the following errors: /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib -u _catch_exception_raise -force_load /var/folders/2n/ql7wkht57cg8wfgzz0cr9trm0000gn/T/tmp31d0b99b.tmp/libAviarySDK.a -ObjC -all_load -fobjc-arc Undefined symbols for architecture i386: "_sqlite3_open", referenced from: -[AFLocalyticsDatabase init] in libAviarySDK.a(AFLocalyticsDatabase.o) "_sqlite3_busy_timeout", referenced from: -[AFLocalyticsDatabase init] in libAviarySDK.a(AFLocalyticsDatabase.o) "_sqlite3_exec", referenced from: -[AFLocalyticsDatabase beginTransaction:] in libAviarySDK.a(AFLocalyticsDatabase.o) * And many other same references * ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status mtouch exited with code 1

Original source