[Mono-dev] Multiplatform support with P/Invoke

Jason Curl jcurlnews at arcor.de
Fri Jan 1 01:15:50 UTC 2016

Thank you Mr. Icaza.

Is there more information on what uses the MapAttribute than what's in 
Syscall.cs? Even though it's internal and I won't use it, I'd like to 
understand how you solve the problem of ABI compatibility.

I'd like to set up a solution where copying the files from one 
architecture to another simply works (assuming all dependencies from the 
runtime are present), and the runtime/mylib chooses the most appropriate 
native library (based on OSVersion and Syscall.uname) for all supported 
platforms. Something like:
* MyLib.dll (assembly)
* MyNativeLib.Linux.x86.so
* MyNativeLib.Linux.x64.so
* MyNativeLib.FreeBSD.x86.so
* MyNativeLib.Darwin.x86.so
* MyNativeLib.Win.x86.dll (windows native)
* MyNativeLib.Win.x64.dll (windows native)
* MyNativeLib.[dll|so] (backup for local builds)

Your solution (Mono.Unix.Native) looks different, more compact, but I'm 
not sure if/how it supports side-by-side. My solution requires a lot of 
work, duplicate code with small changes in defining the 
structs/DllImports with different offsets and library names.

I've yet to look into the Dll mapping mechanism of Mono if that's also 

Thank you very much and for giving me the opportunity to use Mono.


On 2015-12-31 02:04, Miguel de Icaza wrote:
> For something like libc, you can use an approach similar to what 
> Mono.Posix does, where an intermediate C glue file acts as a bridge 
> between the API differences.
> See the P/Invokes for the Mono.Posix assembly, and its supporting glue 
> code in mono/support/
> On Wed, Dec 30, 2015 at 5:58 AM, Jason Curl <jcurlnews at arcor.de 
> <mailto:jcurlnews at arcor.de>> wrote:
>     Hello,
>     I'm investigating the best way on how to support multiplatform
>     software especially when using P/Invokes, but have not found any
>     reasonable advice on the Wiki.
>     Can someone point to me on how to handle different architectures,
>     especially when the underlying libc might use different structures
>     or API signatures?
>     Thanks,
>     Jason.
>     _______________________________________________
>     Mono-devel-list mailing list
>     Mono-devel-list at lists.ximian.com
>     <mailto:Mono-devel-list at lists.ximian.com>
>     http://lists.ximian.com/mailman/listinfo/mono-devel-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20160101/067c6af3/attachment.html>

More information about the Mono-devel-list mailing list