[Mono-dev] DllMap default architecture for P/Invoke
Jason Curl
jcurlnews at arcor.de
Sat Jan 16 13:08:36 UTC 2016
Hello,
I've created a DLL compiled for linux x86-64 and mapping this using
P/Invoke. I'd like to know how a [DllImport("mylib")] can be instructed
to look for the architecture specific library, and if not found, then a
default (probably locally compiled) library for testing.
What I've done until now:
I've created an assembly configuration as per
http://www.mono-project.com/docs/advanced/pinvoke/dllmap/ that looks like:
<?xml version="1.0" encoding="utf-8">
<configuration>
<dllmap dll="libnserial" os="linux" cpu="x86-64"
target="libnserial.Linux.x86_64.so.1" />
<dllmap dll="libnserial" target="libnserial.so" />
</configuration>
The DLL import is:
[DllImport("libnserial")]
public static extern IntPtr serial_version();
The final distribution for the application is expected to have (notice,
no libnserial.so)
libnserial.Linux.x86_64.so.1
libnserial.Linux.x86.so.1
libnserial.FreeBSD.x86.so.1
=> The configuration with Mono 4.2.1 fails with
System.DllNotFoundException: libnserial.so
I remove the second dllmap and it works as expected. But in case the
user builds themselves for local testing and usage, they'll get for
their current architecture an additional library, where I want the
second line to be a fallback in case the library can't be found.
libnserial.so -> libnserial.so.1
libnserial.so.1 -> libnserial.so.1.0
libnserial.so.1.0
How would I handle this scenario within Mono?
Regards,
Jason.
More information about the Mono-devel-list
mailing list