How to Debug a C++ Maya Plugin Using Visual Studio

Introduction

This post is not about creating a C++ Maya plugin, it is aimed at setting up debugging in Visual Studio for the plugin.

note: If you see the word “MayaMorph” in this post, it is because the project I am building is morphing between two geometric meshes. If you are interested there is more info on my website https://nickcullen.net.

Project Setup

We start off in Visual Studio. Open up your Maya plugin solution.

  • 1. Right click your plugins project properties

    Opening Visual Studio Project Properties Example
    Opening Visual Studio Project Properties Example
  • 2. Under Configuration Properties -> Debugging set the "Debugger to launch" option to "Local Windows Debugger".
Debugging Options Configuration Wiindow
Debugging Options Configuration Wiindow
  • 3. In the "Remote Command" entry, you want to put the full path (including extension) to the maya executable. For example my Maya is located at "C:\Program Files\Autodesk\Maya2016\bin\maya.exe" (Yours may be different!).

A handy trick to get the the full path to a file on your windows machine is to hold shift + right click on the executable, then click “Copy as Path“. You can simply paste the value into “Remote Command” removing any quotation marks.

  • 4. Set the "Attach" value to "Yes". This option attempts to attach the debugger to an already running Maya instance. Without this, it will launch Maya every time you launch the debugger.

Your values should look similar to these:

Values of set debugging properties
Values of set debugging properties

Your debugger is all set up.

If you haven’t done so yet, set some breakpoints and open Maya. Don’t run the debugger until Maya is fully open.

Debugging Maya Plugin

Once Maya is fully open, plugin compiled and loaded you can attach the debugger.

1. Click the "Local Windows Debugger" option at the top or simply hit F5
Selecting the debugger to run example
Selecting the debugger to run

Once you execute your plugin from within Maya, you should hit one of your break points like so.

Hitting a breakpoint example
Hitting a Breakpoint

Happy debugging!