Hi,
It looks like the library was written in c++ and so you'll need to use the
c++ linker.
To do this, edit the LinkWith attribute for the libScanAPI.a and set IsCxx
to true, like this:
[assembly::LinkWith ("libScanAPI.a", LinkTarget.ArmV7, IsCxx = true)]
Hope that helps,
Jeff
On Thu, Aug 9, 2012 at 2:15 PM, duartem2u <[email protected]> wrote:
> This will be a long post...I hope someone has the patience to read it to
> the
> end :).
>
> I'm working on a Monotouch project that needs to use an Objective C API for
> a barcode reader.
> The files that come with the API are:
> - A static library libScanApi.a.
> - A couple of .h and .m helper files (ScanApiHelper.h, ScanApiHelper.m)
> that
> use the objects defined in the libScanApi.a library and facilitate the
> integration and usage of the API in an application.
>
> Because the API is quite extensive, I decided to create a new static
> library
> that included the helper files provided by the maker of the API and do
> bindings to this new static library. I ended up with following
> ApiDefinition.cs:
> [BaseType (typeof (NSObject))]
> interface SktManager {
>
> [Export ("initWithDelegate:")]
> IntPtr Constructor (BarcodeReceivedHandler manager);
>
> //-(void) Open;
> [Export ("Open:")]
> void Open ();
>
> //-(void) Close;
> [Export ("Close:")]
> void Close ();
> }
>
> [Model]
> [BaseType (typeof (NSObject))]
> interface BarcodeReceivedHandler {
> //- (void)BarcodeReceived NSString*)value;
> [Abstract, Export ("BarcodeReceived:")]
> void BarcodeReceived (string value);
> }
>
>
> The API documentation mentions that the "External accessory framework" must
> be added, so I changed the LinkWith attribute to include this framework:
> [assembly: LinkWith ("libSktDLL.a", LinkTarget.ArmV7 | LinkTarget.ArmV6 |
> LinkTarget.Simulator, ForceLoad = true, Frameworks ="ExternalAccessory")]
>
> The binding project builds correctly, but the main project that is using
> the
> binding dll (I'm trying to deploy to an iPad) shows the following errors:
>
> /var/folders/hb/f40k80fj0s72pybcz810p_340000gn/T/tmp7166be2e.tmp/libSktDLL.a
> Undefined symbols for architecture armv7:
> "std::terminate()", referenced from:
> -[CommandContext dealloc] in libSktDLL.a(ScanApiHelper.o)
> CSktQueue::CSktQueue()in libSktDLL.a(SktQueue.o)
> CSktQueue::~CSktQueue()in libSktDLL.a(SktQueue.o)
> CSktXmlBracket::~CSktXmlBracket()in libSktDLL.a(SktSimpleXml.o)
> CSktXmlTag::CSktXmlTag()in libSktDLL.a(SktSimpleXml.o)
> CSktXmlTag::~CSktXmlTag()in libSktDLL.a(SktSimpleXml.o)
> CSktXmlParser::Parse(char const*, unsigned long)in
> libSktDLL.a(SktSimpleXml.o)
> ...
> "___gxx_personality_sj0", referenced from:
> -[CommandContext
> initWithParam:ScanObj:ScanDevice:Device:Target:Response:] in
> libSktDLL.a(ScanApiHelper.o)
> -[CommandContext dealloc] in libSktDLL.a(ScanApiHelper.o)
> -[CommandContext doCallback:] in libSktDLL.a(ScanApiHelper.o)
> -[ScanApiHelper init] in libSktDLL.a(ScanApiHelper.o)
> -[ScanApiHelper isDeviceConnected] in libSktDLL.a(ScanApiHelper.o)
> -[ScanApiHelper open] in libSktDLL.a(ScanApiHelper.o)
> -[ScanApiHelper removeCommand:] in libSktDLL.a(ScanApiHelper.o)
> ...
>
> The output shows allot more errors. I've shown the top two for the sake of
> brevity.
>
> If I remove the LinkTarget.ArmV7 from the LinkWith attribute, the main
> project compiles correctly but the app crashes as soon as I make a call to
> the 'Open' method. No exception is thrown, the app just crashes instantly.
>
> I took a look at the Organizer window in Xcode but I don't know how to
> interpret the device log information for the crash:
> Incident Identifier: 0ABEEDA2-15EA-49B6-82D9-C1346AAA5A5C
> CrashReporter Key: 094b535c4ce505f7f3987594c5248358746a1538
> Hardware Model: iPad2,2
> Process: TestSktDllBinding [5997]
> Path:
>
> /var/mobile/Applications/FE82B8DF-C025-4AC3-B474-3726FD42D782/TestSktDllBinding.app/TestSktDllBinding
> Identifier: TestSktDllBinding
> Version: ??? (???)
> Code Type: ARM (Native)
> Parent Process: launchd [1]
>
> Date/Time: 2012-08-09 17:34:30.273 +0100
> OS Version: iPhone OS 5.1.1 (9B206)
> Report Version: 104
>
> Exception Type: EXC_BAD_ACCESS (SIGSEGV)
> Exception Codes: KERN_PROTECTION_FAILURE at 0x2fd00fc0
> Crashed Thread: 0
>
> Thread 0 name: Dispatch queue: com.apple.main-thread
> Thread 0 Crashed:
> 0 TestSktDllBinding 0x00501978 monotouch_trampoline
> (monotouch-glue.m:804)
> 1 TestSktDllBinding 0x0018ae44
>
> wrapper_managed_to_native_MonoTouch_ObjCRuntime_Messaging_void_objc_msgSend_IntPtr_intptr_intptr_intptr
> (monotouch.dll.7.s:32355)
> 2 TestSktDllBinding 0x00345014
>
> wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
> (mscorlib.dll.7.s:149759)
> 3 TestSktDllBinding 0x00451728
> mono_jit_runtime_invoke (mini.c:5786)
> 4 TestSktDllBinding 0x004c1e18 mono_runtime_invoke
> (object.c:2757)
> 5 TestSktDllBinding 0x00502610 monotouch_trampoline
> (monotouch-glue.m:808)
> 6 TestSktDllBinding 0x0018ae44
>
> wrapper_managed_to_native_MonoTouch_ObjCRuntime_Messaging_void_objc_msgSend_IntPtr_intptr_intptr_intptr
> (monotouch.dll.7.s:32355)
> 7 TestSktDllBinding 0x00345014
>
> wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
> (mscorlib.dll.7.s:149759)
> ....
>
> I've tried to use the static library that I created in another Xcode
> project
> and it worked fine. Am I doing something wrong regarding the bindings?
>
> Thanks
>
>
>
> --
> View this message in context:
> http://monotouch.2284126.n4.nabble.com/Problems-creating-bindings-to-a-barcode-reader-API-tp4656449.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch