Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a native static library (.a) to a Xamarin.Mac project

Tags:

xamarin

native

Xamarin Mac has a folder called Native References. However, when adding native static libraries (.a), it seems to do absolutely nothing. Ideally I would like to use T exported methods by using DllImport("__Internal"....)

How can I get this to work?

like image 663
tofutim Avatar asked Nov 10 '22 13:11

tofutim


1 Answers

This a rather late reply, but just in case anyone else comes across this in the future, note that currently it is not possible to use static .a libraries with Xamarin.Mac because Xamarin.Mac does not perform any native linking. That is, it does not invoke clang or ld at all during the build process. Instead, it just copies a pre-built "launcher" executable into the Contents/MacOS/ folder in the .app bundle.

On the other hand, .dylib libraries should work, as long as they're compiled for x86 and have all their dependencies. I recently wrote up a little guide on using dynamic libraries in Xamarin.Mac that might be helpful.

like image 98
Brendan Zagaeski Avatar answered Jan 04 '23 01:01

Brendan Zagaeski