Wrap c++ function to develop plugin

I am developing a rhino grasshopper plugin. I wrap c++ CGAL library function into C#, compiling it as a dll.file. And however, I found if the user wants to use this, they have to install C++ on their own computer. (use Visual Studio to download and install).

The user has installed rhino. Rhino is developed based on c++. isn’t it? Why is the user able to run Rhino without installing c++. Does it make sense?

Here is the chat with ChatGPT. Is that a correct answer?

Users don’t need to install any compilers or IDEs. But you as the developer of your plugin need to bundle all the dependencies that make your plugin work. So if your plugin depends on CGAL then you need to bundle all the DLLs that together form CGAL in addition to the assembly you create.

If you compile the CGAL library with a very modern compiler, or very old compiler for that matter, you may have to ensure that the correct vc runtime distributables get installed.

1 Like

you could also run into this if you mistakenly distribute debug binaries

1 Like

Thanks for your reply. I am trying to figure out what minimal dependencies my function needs instead of installing the whole c++ package.

What do you think is the whole C++ package?

To clarify my case:

Before going to the C# development environment I am currently testing my own built dll. with python first.

So I have a C# wapper called CGAL.wrapper.dll and a C++ native function called CGAL.Native.dll.
Using clr I can import dll. I used this way to use kangarooSolver.dll, Plankton.dll…


My GHpython script works immediately after I installed “this whole thing” on someone’s computer. :point_up_2:

Before installing I got this error msg on his computer. I have tried to copy it everywhere, the grasshopper file folder, grasshopper library folder, set the system environment path, set the rhino python editor module search path etc…:point_down:

You should investigate with GitHub - lucasg/Dependencies: A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues. what all the requirements are for CGAL.Native.dll . Then make sure all of the mentioned DLLs are available in the load location. Also you need to make sure it is compiled correctly.

You as developer may want to have C++ tools installed if you need to compile the native function DLL, but your users will not have to if you manage to bundle your plug-in correctly.

1 Like

Many thanks for your quick response. It will help a lot!

if you are using current cgal 5.x, which indicates it is a header-only library (since v5), then I infer that you are compling this cgal dll yourself, and that you are doing this with visual studio 2022 as shown in your screenshot

if so, and if it works when you have your user install visual studio 2022, then it is likely you are using the v143 toolset to build, and should have your user install the current msvc++ redist

rhino 7 uses v140, so any redist that it installs for its own purposes will not be sufficient for your build (provided I am guessing correctly about what you are doing)

1 Like

Hey! I will give it a try.
Thank you so much for the tip!

Update. It might be my fault. When I distribute the plugin, I should use "release mode " to compile instead of “debug mode”