How are menu commands associated with CRhinocommand

How are menu commands associated with CRhinocommand

You can check this guid:

I have read this tutorial, but it only teaches you how to add menu items. What I want to ask is that when I click the menu item, I should activate a rhino command, that is, associate the menu item with Rhino command.This command may be my own code or rhino’s own function

In the document you’ll see that the MENUITEMINFO struct gets also an ID set IDR_MY_MENU. Not shown in this particular document is that you are supposed to react to that in the implementation of OnPluginMenuCommand and run your command using RhinoApp(),RunScript().

See for instance

for a sample doing that.

Here the implementation for RunCommandScript

Why does an unexplained external symbol appear:

Are you able to compile the developer sample code? Most specifically this project rhino-developer-samples/cpp/SampleUserInterface at 7 · mcneel/rhino-developer-samples · GitHub, but trying to compile the entire C++ sample solution would be a good test: rhino-developer-samples/cpp at 7 · mcneel/rhino-developer-samples · GitHub

It can be compiled normally

I think you’ll find it works better if you don’t do auto app = RhinoApp();, but always directly RhinoApp() wherever you need access to its API.

Or if you really must use explicit CRhinoApp& instead of auto to ensure you get a reference, and not a copy.

addendum: you could also use auto& app = RhinoApp();

As you said, I have solved the problem