How to compile RH6 c++ dll


#1

The c++ plugin compiled perfectly but it is also giving .rhp
How to get .dll ?

and can I use c++ plugin dll as reference to my c# dotnet plugin?

How can I get .dll compiled. Is it a different process?

Do I need to write a CLI in c++ to use it in c#?
I do not work in c++, so please do not mind if I ask any meaningless question.
Thanks in advance for the help.


(Steve Baer) #2

What is the goal that you are trying to achieve? It would help me figure out how to best answer your questions.


(Menno Deij - van Rijswijk) #3

You can use P/Invoke from a C# assembly to call a function inside a C++ dll. The nice thing is that you don’t need a .dll file, this can be done directly into the .rhp file!

For example, we have in a C# assembly the following declaration of an extern function (that exists in the C++ plug-in)

[DllImport("MyCPlusPlusPlugIn.rhp")] // refer to the Rhino C++ plugin
public static extern void SetShowLines(bool value);

and inside our C++ plug-in we have the function

extern "C"
{
  __declspec(dllexport) void SetShowLines(bool value)
  {
    // gets called from C#, do stuff in C++ here
  }
}

The extern "C" {...} is necessary to get so-called unmangled function names in the C++ DLL; and the __declspec(dllexport) is needed so that the name of the function is visible to users of the DLL.

That is all there is to it!


#4

Thanks Steve and Menno !
@menno , you Gave me some ideas, which is very helpful to start with.
Problem is, I forgot c++ All the time writing c# dot net, so now struggling badly to get head around with c++ sdk…Codes at front of me from 7 years back. all looks like Chinese language ! :slight_smile:
But Your advise is very helpful to start with! and this is all I wanted to know for now.
Will catch up soon.

Many thanks.