[Mono-list] interop with native C DLL on MAC OS X

Gigi Sayfan gsayfan at numenta.com
Tue Feb 16 14:25:52 EST 2010

Hi everybody,
Here is the situation:

I have a C++ library that I wrapped using Swig for C#. The result is a low-level .so file that contains a C wrapper for the C++ library and a bunch of C# files that talk to .so file via P/Invoke calls.

So far, so good.

I created a test program that included all the generated C# files and I was able to call the C++ code successfully through all the layers.

BTW, I'm using MonoDevelop as my IDE. I had some problems finding the .so file and eventually after reading http://www.mono-project.com/Interop_with_Native_Libraries I settled on the following solution:

- Put the .so file in the same directory as the .exe file and create .config file for the .so file that looks like that:

  <dllmap dll="net" target="net.so" />

Now, I want to wrap the whole mess in a non-executable assembly that will add a nicer interface and hide all the low-level stuff generated by Swig. So, I created
a library project, added all the Swig generated C# files, added my nice interface class that uses the low-level stuff.

The new library project builds just fine and created a net.dll file.

I created a new test program that references the net.dll and calling the nice interface. This program builds fine too.

When I try to run this program I get again a System.DllNotFoundException

I added a config file called net.dll.config, but this time it didn't help. I even tried to map to the absolute path of the .so file to no avail. I know that the config file is used because the DllNotFoundException in the output says it can't find the target DLL with the full absolute path.

Any ideas what I should try next?

Thanks, Gigi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20100216/1c5c8201/attachment.html 

More information about the Mono-list mailing list