2

I’m working on Xamarin and trying to install an iOS app on my iPad.

I want to link an Ada static library.

So I have a libMyLibrary.a + libgnat.a file and a C header code (MyLibrary.h).

  • In Xamarin, I created a binding library project and added my library.
  • In Xamarin, I added the above project as a reference to my iPad app.

To communicate with the library I used the P/Invoke with a DllImport(“__Internal”) and an assembly for my lib (so I don’t have any MTouch arguments) :

[assembly: LinkWith(“libMyLibrary.a”, SmartLink=true, ForceLoad=true)]
[assembly: LinkWith(“libgnat.a”, SmartLink=true, ForceLoad=true)]

But when I deploy it to the iPad I have a lot of native linking errors:

Native linking error: warning: could not create compact unwind for XXX does not use standard frame (MT5209)

I tried to use the monotouch arguments but no success:

Any ideas?


Configuration:

  • iOS 10.3.2
  • Xamarin 6.3
  • Deployment target 10.3
T.E.D.
  • 44,016
  • 10
  • 73
  • 134
LoneWanderer
  • 3,058
  • 1
  • 23
  • 41
  • I admire the problem of compiling C# code for iOS while linking to a static Ada lib. And for the more helpful part of the comment: Did you check that the static Ada library is compiled for the correct architecture (i.e. the iOS ARM architecture)? Perhaps try to link it to ObjC to make sure that it works at all. – flyx Jun 19 '17 at 13:51
  • Hello, the question is legitimate, and yes : I do have the Ada library compiled for the correct target and the lib interfaces are C compatible, which I do believe is a safe choice). In fact, I foundfound a solution for this, I need a few moments to post the answer. – LoneWanderer Jun 19 '17 at 16:15

1 Answers1

3

After struggling around with this for a few days, we came up with something working.

The exact directives we've given to Monotouch are as follows:

-gcc_flags "-L${ProjectDir} -lMyLibrary -lgnat -force_load ${ProjectDir}/libMyLibrary.a -Wl,-no_compact_unwind"

Notice that :

  • the gnat lib file is put aside libMyLibrary.a
  • libMylibrarry is referenced twice in the command

And ... voilà !

Apprently, I didn't add it properly at the first time...

LoneWanderer
  • 3,058
  • 1
  • 23
  • 41