How to migrate C++ DLL from Visual Studio 2017 & Rhino 6 to Visual Studio 2019 & Rhino 7

@dale,

When trying to migrate my C++ DLL from Visual Studio 2017 & Rhino 6 to VS 2019 & Rhino 7, I was following your directions “Creating your first C/C++ plugin for Rhino” but I could not get past the first two steps:

  1. Launch Visual Studio 2019 and navigate to File > New > Project… .
  2. From the New Project dialog, select the Rhino 7 Plug-in template from the list of installed templates and click Next .
    This template is not shown after my install of VS 2019. This iswhat I see even after searching for Rhino 7 plug-in

Do I need to install VS 2019 with different options (I choose C++ package as optional element)? Do I need to look elsewhere in VS 2019?

Edit: I traced back from your page to a page about tool installations and I see I may have not checked all the needed options for VS 2019. I will uninstall and try again.

Thanks for any help.

Regards,
Terry.

You should be able to install the Rhino templates from the Tools > Extensions menu in Visual Studio. It is not an install option.
Edit: the templates are also installed with the Rhino SDK.

Be sure to follow this guide to configure the VS install

Yes, this is the page I was sent to from Dale’s page on 1st plugin. My case is a bit trickier as I am creating a C++ DLL to call from my Python script. Dale gave directions for doing this by starting with the plug-in flow and then removing some .cpp and .h files and another change involving the Solutions manager.

I have done this successfully in the past with VS 2017 and Rhino 6. Now I am doing it again with VS 2019 and Rhino 7. Hopefully I will get it working by tomorrow (traveling now).

It would be nice if a template was created for this DLL-only case. Many struggle to get this case to work and I have not been able to help them much as I have done it so few times and have such thin documentation on how to do it (no screen shots of the Solutions Explorer window or Property Manager window of before and after file removal).

Thanks for your help.

Regards,
Terry.

Step 4 in the SDK install process, linked by @menno, is critical.

– Dale

Yes, step 4 is what made the Rhino plug-in templates show up. Now done traveling coast-to-coast, replacing my obsolete Xfinity cable modem and my failed wireless router so I can get back to work on getting VS 2019 working with Rhino 7 to generate C++ DLL for my Python pointcloud script. Wish me luck.

Regards,
Terry

1 Like

@dale, @menno,

With your help I was finally able to create a C++ DLL in VS 2019 that works with my Python script running in Rhino 7. Following your written directions from 3 locations about (1) tools, (2) first plug-in creation and (3) special modifications to create a stand alone DLL vs a plugin, I ended up with the Solution Explorer window in Visual Studio 2019 showing this after I copied over my Cloud_Mesh_Functions.cpp file from Visual Studio 2017 which worked without changes:

while the Property Manager shows;
image

With this update, I can now continue my work on Pointcloud analysis.

I do have a few questions about the differences from VS 2017/Rhino 6 to VS 2019/Rhino 7:

  1. Inside stdafx.h it says:
// This plug-in is Rhino 6 ready
#define RHINO_V6_READY

Why does this not say it is RHINO_V7_READY ?

  1. The compiler now generates new, noisy warning messages (stretches over multiple lines) when compiling the xstring module:

    1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\xstring(2468,23): warning C4244: ‘argument’: conversion from ‘wchar_t’ to ‘const _Elem’, possible loss of data
    1> with
    1> [
    1> _Elem=char
    1> ]

This comes from the string code:

    template <class _Iter>
    void _Construct(_Iter _First, const _Iter _Last, input_iterator_tag) {
        // initialize from [_First, _Last), input iterators
        _Tidy_deallocate_guard<basic_string> _Guard{this};
        for (; _First != _Last; ++_First) {
            push_back(*_First);
        }

        _Guard._Target = nullptr;
    }

Another one is:

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\xstring(2479): message : see reference to function template instantiation ‘void std::basic_string<char,std::char_traits,std::allocator>::_Construct<wchar_t*>(_Iter,const _Iter,std::input_iterator_tag)’ being compiled
1> with
1> [
1> _Iter=wchar_t *
1> ]
from the xstring code:

    template <class _Iter>
    void _Construct(const _Iter _First, const _Iter _Last, forward_iterator_tag) {
        // initialize from [_First, _Last), forward iterators
        const size_type _Count = _Convert_size<size_type>(static_cast<size_t>(_STD distance(_First, _Last)));
        reserve(_Count);
        _Construct(_First, _Last, input_iterator_tag{});
    }

Regards,
Terry.

Because we didn’t change the definition.

Also keep in mind that Rhino C++ plug-in work in Rhino 7. So I assume Rhino-dependent DLLs, compiled against the Rhino 6 C++ SDK will also work in Rhino 7.

I haven’t see the other warnings/errors…

– Dale

Yes my VS 2017/R6 C++ DLL works fine in R7. I moved to VS 2019 in the hope of better debug support and better features.

Regards,
Terry

Menno,

Now I cannot get the flow to work for creating a C++ plugin. The Wizard that creates the Rhino 7 Plugin template does not appear in the list of choices when I go to create a new project in Visual Studio. What is the magic that informs Visual Studio that the Rhino 7 Plugin template is available? I install Visual Studio, I install the Rhino 7 SDK but how does Visual Studio know that the Rhino 7 Plugin template is there? I am not getting how this works so I do not know how to fix it. It worked once in the past when I followed the link you provided, but it is not working for me now.

Regards,
Terry.

Step 4 under “Install Visual Studio” is important.

Then just search for “Rhino”.

– Dale

Dale,

This procedure no longer works. My Visual Studio definitely has Visual Studio SDK installed as shown by the Modifying screen if I try to modify the installation:


Then in Create a new project the search for Rhino turns up nothing:

Apparently the Visual Studio SDK no longer carries the information about the Rhino 7 Plug-in.

I have tried uninstalling Visual Studio 2019 and Rhino C/C++ SDK, confirmed that they were removed, reinstalled them carefully following your guide and get the same result above.

What to do?

Regards,
Terry.

Do you see these file in this location?

– Dale

Dale,

Yes I see those files. And I have now gotten Visual Studio 2019 to recognize the Rhino 7 Plug-in. To achieve this, I used the Visual Studio Installer to Modify my installation to remove the Visual Studio SDK. Then Visual Studio started recognizing the Rhino 7 Plug-in. I used Modify again to put it back and the Rhino 7 Plug-in still appears as a choice.

Apparently Visual Studio has some kink of hiccup that stomps on the recognition of the Rhino 7 Plug-in options. After bashing it many times, it eventually gave me back this option. The key was doing a Modify to remove the Visual Studio SDK. Makes no sense but that got it working again.

Regards,
Terry.