[Mono-list] System.DllNotFoundException
Jonathan Pryor
jonpryor@vt.edu
Thu, 08 Apr 2004 18:18:13 -0400
Below...
On Thu, 2004-04-08 at 14:39, Martin Welch wrote:
> I have a simple c# app trying to PInvoke to a shared library on my
> Mandrake 10 box using Mono-0.31.
>
> I assumed that mono would look in the current directory but it seems
> my assumption is wrong since the so in question does exist.
You need to read my "life changing" guide, "Everything you (n)ever
wanted to know about Marshalling (and were afraid to ask!)". In
particular, you want the "Linux Shared Library Handling" section:
http://www.jprl.com/~jon/interop.html#library-linux
The short version: you need to add the directory containing the shared
library to the LD_LIBRARY_PATH environment variable:
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}`pwd`
mono my-app.exe
(Yes, that LD_LIBRARY_PATH export is...long. You'd probably wonder why
"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`" wasn't used. The answer
is security: if LD_LIBRARY_PATH is the empty string, you'd have
":`pwd`", which adds the current-working-directory to the search list.
This would allow a malicious individual to insert a trojaned library
into your application. See: http://www.gnome.org/~markmc/blog/07042004.)
- Jon