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

Duane Wandless duane at wandless.net
Mon Jan 4 10:42:11 EST 2010


I recommend the dllmap approach when embedding.  I could not get any of the
environment variables to be correctly set and read at runtime.  I'd set it
during the app load routine, init mono and mono would fail to find the
library.  If I set the environment variable prior to launching the app mono
could find the library.  Using the dllmap I'm able to set at runtime where
my dylib is located, which is within the app itself.

Duane

On Mon, Jan 4, 2010 at 3:40 AM, Michael Hutchinson <m.j.hutchinson at gmail.com
> wrote:

> 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:
> <snip>
> > 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
> script.
>
> AFAIK the "done thing" for library paths on Mac is to use absolute
> paths, with some variables - the following explains this:
>
> http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html
>
> With Mono, I'd use dllmaps and DYLD_FALLBACK_LIBRARY_PATH.
>
> --
> Michael Hutchinson
> http://mjhutchinson.com
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100104/1a5818d7/attachment.html 


More information about the Mono-osx mailing list