Running Panda3D under the C++ Debugger

Don't mind the mess!

We're currently in the process of migrating the Panda3D Manual to a new service. This is a temporary layout in the meantime.

These instructions show how to compile and run panda from inside the Microsoft Visual Studio debugger.

Before you Begin

The first step is to download the panda source code and compile it. The instructions can be found in the section Building Panda3D from Source. Be sure to compile with the Optimize setting of 1, otherwise, Visual Studio will not be able to debug properly. Once you have compiled panda, start up visual studio, and ask it to create a new project:


Debugpanda1.jpg


There are four pieces of information you need to enter into the new project dialog:

  • Tell it to make a "C++ project"
  • Tell it to use a "Makefile"
  • Tell it the name of the project, "debugpanda"
  • Tell it where the panda source tree is (ie, "c:\panda3d-b")

Debugpanda2.jpg


Click ok, and confirm. You have now created the project, and the project is open for editing. You now need to access the "solution explorer:"


Debugpanda3.jpg


Normally, you can see the solution explorer in the upper-right corner of visual studio. It should show your project name (debugpanda). The word "debugpanda" needs to be highlighted - if it is not, click on it:


Debugpanda4.jpg


Now that your project is selected, you can edit its project properties:


Debugpanda5.jpg


The project property dialog initially looks like this. It contains three subpanels, the "General" panel, the "Debugging" panel, and the "NMake" subpanel. You can see these three subheadings in the left pane:


Debugpanda6.jpg


There is nothing to fill in on the general panel, so switch to the debugging panel. You need to fill in the command name, the command arguments, and the working directory. For now, we will ask it to debug the Actors/Robots sample program. Since visual studio puts the project file in a subdirectory, the paths need to be preceded by ".." to get to the root of the panda source tree:


Debugpanda7.jpg


Finally, switch to the "NMake" panel. Here, you can tell it what the command is to recompile panda. I use a bat file "mkp.bat" to compile panda. Since the project file is in a subdirectory, the command needs to be preceded by "cd .." in order to get back to the root of the panda source tree:


Debugpanda8.jpg


Visual studio now knows how to run panda, and how to compile it. You can run your program (in this case, the "Actors/Robots" tutorial) by clicking on the Debug menu:


Debugpanda9.jpg


You can rebuild panda at any time by clicking on the "Build" menu:


Debugpanda10.jpg


Now that you are running in the debugger, you can open any panda source file and set a breakpoint, or examine data. Of course, it may be advantageous to learn how to use the python debugger as well as the C++ debugger.

Previous Top Next