Issues when wrapping C++ library for .NET (Mac only)

Hi,

I’m following the guide to wrap a C++ library in order to call it from .NET. It would be greatly appreciated if the repository SampleNativeLibrary was updated according to the latest Rhinocommon add-in for Visual Studio for Mac (@dale? @dan?); currently upon download it doesn’t compile. Though this is not the focus of this post.

I’m building a C++ library with Xcode and want to wrap it to be called in a Rhinocommon plug-in in Rhino for Mac. From Xcode I get a .dylib, say SampleLibrary.dylib. Now I’m stuck in the following points of the guide:

  1. In point SampleNativeLibrary -> Mac -> 6 the wrapped library is referenced as
internal static class Import
 {
   public const string lib = "SampleLibrary.dll";
 }

I understand that here we reference a .dll because the guide is about a cross-platform project where the wrapped library may come from Windows, but what if it just comes from Mac? Is it possible to directly reference SampleLibrary.dylib and skip all the following steps of the guide?
Otherwise, how would I get SampleLibrary.dll if I’m using Xcode?

  1. In point SampleNativeLibrary -> Mac -> 9 -> 2 (After Build 1), the guide says this step copies the SampleLibrary.dll.config file from the /SampleLibrary folder to the target folder, but in the code I see this line
cp SampleLibrary/SampleRhino.dll.config ${TargetDir}/SampleRhino.dll.config

What is SampleRhino.dll.config and how was it built?
Similar to my question above, is it possible to skip this mapping between dll and dylib if I restrict myself to Mac environment?

  1. In point SampleNativeLibrary -> Mac -> 9 -> 3 (After Build 2), this step copies libSampleLibrary.dylib to ${SolutionDir}/bin/ folder. I wonder here why the .dylib file has to move to a new folder called bin. The guide says it’s because .NET project will call this folder, but where in the .NET solution is it enforced that this folder will contain the wrapped libraries? I couldn’t find it in the project properties.

Thank you,
Pablo

Hi @Pablo_Garcia-Amorena,

If you are just using the Mac, then perhaps this is of use?

https://www.mono-project.com/docs/advanced/pinvoke/

– Dale

Thanks @dale, that’s very useful.

Pablo