[Mono-dev] DllNotFoundException and shared libraries
Raja R Harinath
rharinath at novell.com
Thu Dec 15 02:03:43 EST 2005
Andrew Warinner <awarinner at gmail.com> writes:
> I'm getting a System.DllNotFoundException when attempting to execute a
> function in a shared library that in turn executes a function in yet another
> shared library.
> Here's the function declaration in the C# source:
> [DllImport ("libfontinfo.so")]
> public static extern int init_font_library();
> libfontinfo.so is contained in the ld.so.cache as evidenced by /sbin/ldconfig:
> libfontinfo.so.1 (libc6) => /usr/lib/libfontinfo.so.1
But, do you have libfontinfo.so? Note the lack of the major number in
the DllImport line.
Unless you have reason to require the development package associated
with a shared library, it's probably not a good idea to DllImport the
naked .so extension.
'DllImport'ing a specific major number is also a good idea for other
reasons: a change of major number signifies an API change -- which
probably could silently make your DllImport line incorrect. We don't
use any sort of C header files to validate the DllImport signature. Put
another way: the naked libfoo.so symlink points to the shared library
that corresponds to installed C/C++ headers files. Since we don't use C
headers, we shouldn't be using that symlink.
More information about the Mono-devel-list