Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 5361 [details]
App project that consumes the native C static library
Created attachment 5362 [details]
Static C library Xcode project
In the process of trying to learn how to link native libraries in Xamarin.iOS, I'm trying to link a very simple static C library in a Xamarin.iOS project. Xamarin however seems to be unable to find the library whenever I try to access a function from the library. The library consists of only one source and header file, with one function (Hello world), and is made in Xcode (as a C library project). I've followed you're guide on linking native libraries (http://docs.xamarin.com/guides/ios/advanced_topics/native_interop). I have built the static library using the terminal, as you suggest in the guide, and I get the *.a file as expected. After importing the .a file to a Xamarin.iOS project, and linking it, the problem appears when I try to access my Hello world function from the library using P/invoke. When debugging, I get a DllNotFoundException when the function from the library is called. I have run out of ideas on how to solve this, and hope you can help me.
This is the first real problem I've encountered using Xamarin, and I really want to congratulate you guys on making a very powerful cross platform development tool. It's been a joy working with both Xamarin.iOS and Xamarin.Android!
There a few things wrong here. First:
^ that's bad - because a ".a" is a static library and once natively linked it will be part of the main executable (the ".a" is not shipped in the app).
In order to look for the native method inside the main executable you need to use the special "__Internal" name, e.g.
This is documented in the above link  in the "Static Libraries" section.
Next you're not giving any instruction to to link to this static library. As such it is not linked to the application and it the `Hello_World` function won't be part of the native executable (and won't be found).
This is also part of , see "Configure Xamarin.iOS To Link the Library"