[Mono-osx] Beginner - Very Simple P/Invoke Example?

Michael Hutchinson m.j.hutchinson at gmail.com
Mon Jan 4 03:40:47 EST 2010

On Sun, Jan 3, 2010 at 5:15 PM, cannyshammy <mike.cann at gmail.com> wrote:
> Im new to Mono development tho I have done a fair bit of XNA stuff. For this
> current project however I need to catch system-wide input events so I need
> some native code for that.
> Im trying to get a very simple P/Invoke example working on OSX. My C looks
> like:
> But it throws me the following error:
> Unhandled Exception: System.DllNotFoundException: libXCodeMono.dylib
>  at (wrapper managed-to-native) SimpleMacMonoHook.MacHook:myMethod (int)
>  at SimpleMacMonoHook.MacHook..ctor () [0x00006] in

My guess would be that when loading dynamic libraries, MacOS isn't
looking in the directory your program's in. Try setting
DYLD_FALLBACK_LIBRARY_PATH to your program's directory in your launch

AFAIK the "done thing" for library paths on Mac is to use absolute
paths, with some variables - the following explains this:

With Mono, I'd use dllmaps and DYLD_FALLBACK_LIBRARY_PATH.

Michael Hutchinson

More information about the Mono-osx mailing list