How to create C++ Plugin for Maya
GOAL
To set up the environment for C++ Maya plugin. To build sample plug-in and execute it.
Environment
Maya 2018
Maya 2018 Update 6 win64 DevKit
Windows10 with environment for C++ compile
Microsoft Visual C++ 2017 ver15.8.4
Method
Get Maya DevKit
Access Maya Developer Center. And scroll down to click “Maya <version> Update 6 win64 DevKit”. Then unzip the file.
Setting up the build environment
Refer to Autodesk Maya Document “Setting up your build environment“.
Add the 3 directories, \devkit , \mkspecs in devkitBase into Maya installation directory (e.g. C:\Program Files\Autodesk\Maya2018).
* To compile custom plug-ins, you can also find the C++ API header files(\include\maya ) and libraries(\lib).
Build enclosed plug-ins in Visual Studio
Open devkit/plug-ins folder( either maya installation folder or newly created folder where plug-in folder is copied and put would be fine). I create a folder named “maya_cpp_plugin” and copy plug-in files to the new folder.
Find “Hello World Cmd” and open it.
![](https://s-nako.work/wp/wp-content/uploads/2019/08/maya_cpp_hello1.png)
Add folder “include” into the list of include directories for Visual Studio. Right Click the name of project name and open Properties.
![](https://s-nako.work/wp/wp-content/uploads/2019/08/maya_cpp_hello2_5.png)
Then, add ” C:\Program Files \ Autodesk\Maya2018\include” into the Additional Include Directories.
![](https://s-nako.work/wp/wp-content/uploads/2019/08/error1089.png)
Add ” C:\Program Files\Autodesk\Maya2018\lib” into Additional Library Directories.
![](https://s-nako.work/wp/wp-content/uploads/2019/08/maya_cpp_hello4.png)
Open solution file *.sln, then Visual Studio will start up. Click Build > Build Solution.
![](https://s-nako.work/wp/wp-content/uploads/2019/08/maya_cpp_hello2.png)
The output files are in the directory maya_cpp_plugin\helloWorldCmd\x64\Release(or Debug). “helloWorldCmd.mll” is the main plugin file.
Plug-in installation
Refer to Autodesk Maya Document “Installing a Maya plug-in“.
Add plugin helloWorldCmd.mll to the plug-in directory defined as MAYA_PLUG_IN_PATH in <username>\Documents\maya\<version>\Maya.env file. If Maya.env doesn’t exist, create it according to “Setting environment variables using Maya.env“.
Start Maya and open Plug-in Manager.
![](https://s-nako.work/wp/wp-content/uploads/2019/08/maya_cpp_hello5.png)
Click a check mark next to helloWorldCmd.mll
![](https://s-nako.work/wp/wp-content/uploads/2019/08/maya_cpp_hello6.png)
Execute the Plug-in with command
Open Script Editor and execute the Command “helloWorld”.
![](https://s-nako.work/wp/wp-content/uploads/2019/08/maya_cpp_hello7.png)
![](https://s-nako.work/wp/wp-content/uploads/2019/08/maya_cpp_hello8.png)
The message “helloWorld” is displayed on the console, upper side of the Script Editor.