I am using several P/Invokes under .NET. However, I want my library to work both in Windows and Linux, preferably with the same binaries.
Since the native library I depend on is available on multiple platforms, I was hoping to just have them along with my managed library's binaries.
Right now I'm using something like this:
[DllImport("/usr/lib/libMYLIBNAME.so.1")]
But this obviously only works for Linux. I was considering that I could possibly copy that binary from /usr/lib and distribute along with my application, so I could reduce the above to:
[DllImport("libMYLIBNAME.so")]
But this still is Linux-only.
Is there anyway to change the library name string so it'd look for libMYLIBNAME.so under Linux and MYLIBNAME.dll on Windows, or something very similar?
I would like to avoid anything that requires recompilation for each supported platform...
(Note: even better would be a solution that'd look for MYLIBNAME.dll on Windows and /usr/lib/libMYLIBNAME.so.1 on Linux, but this improvement is optional)