[Mono-osx] How can a custom library be included in a package.
Geoff Norton
gnorton at novell.com
Wed Feb 2 20:34:45 EST 2011
Hello,
On 2011-02-02, at 7:25 PM, JasonZ wrote:
>
> I have a MonoMac project that depends on some libraries that are not part of
> the MonoMac project and not standard to OS/X. When I build a Mac Installer
> the libraries are not included... I would like to manually include them.
> How is that done?
>
> The details of this project are a bit complex, so if the question above
> cannot be answered here's some more info:
>
> This is a project I inherited and it includes
> - third party libraries
> - C libraries (as part of the project but not in MonoDevelop)
> - .Net UI
> - command line executable written in C (not .Net)
>
> I can compile and run the project fine on OS/X. I can build an application
> bundle (which doesn't include the libraries or command line executable)
> which runs on the development machine. The application bundle does not,
> obviously, run on any other machine because it doesn't include the
> libraries.
We're working on a more general system for external frameworks and libraries, but in the meantime you can add the native dependencies and add them to your project as, and mark them as "Content". This will end them up in the "Resources' directory of your application bundle.
The monomac bundler currently (subject to change) does a cwd into the Resources directory before beginning execution, so I think [DllImport ("libname.dylib")] should just work, if it doesn't you can use the newly exported Dlfcn class in MonoMac.ObjCRuntime, and Dlopen the explicit path built from NSBundle.MainBundle.ResourcePath + libname.dylib, then [DllImport ("__Internal")] will work.
As stated earlier, we're planning on cleaning this up going forward, but that should get you going for now.
As for your command line executable, it should look in cwd for $PATH, so it should just be fine.
-g
More information about the Mono-osx
mailing list