Panda3D Manual: How to build a CXX Panda3D game using Microsoft Visual Studio 2008

Note: As of at least Panda version 1.7.2, the pre-built DLL's provided for download from this site are compiled with Microsoft Visual Studio 2008, which is not compatible with other versions of Microsoft Visual Studio. Therefore, you must also use Visual Studio 2008 to compile your own application; you cannot use Visual Studio 2010 or any other version.

It is possible to compile Panda using 2010, but in order to do this you must download Panda from source and build all of Panda yourself, rather than using the pre-built DLL's available here. You may also need to recompile some of the thirdparty DLL's, though there are conflicting reports on this. Many people find it easier just to use Visual Studio 2008.

Steps to compile C++ in Visual Studio 2008

Open Visual Studio 2008 and start a new project.

Step one: Set project mode (very important!)

You must set your new project to "Release" mode. This is absolutely necessary, because the version of Panda that's provided for download on this website is also built in "Release" mode, and in MSVS, you can't mix-and-match Release and Debug projects, especially if both of them are C++.

If you attempt to build your code in "Debug" mode, everything may appear to build correctly, but when you attempt to run the program, it will crash in mysterious ways.

(In the future, we may provide an optional "Debug" build for download from this site. In this case, you must be careful to choose "Release" for your project when you are linking against the "Release" Panda build, and "Debug" for your project when you are linking against the "Debug" Panda build.)

Also very important: you must remove the NDEBUG macro definition from your project file. MSVS automatically defines this when you set the project to Release mode, but it isn't appropriate to set this unless you really are making the final build of your project before releasing it to users. Also, in Panda version 1.6.x, leaving this defined will cause mysterious crashes when you run your program. (This will not be true of Panda version 1.7.x or later, but it is still a good idea to remove it.)

Step two: Add directories

You need to add directories corresponding to your installed Panda3D version. If you installed to C:\Panda3D-1.6.2, for example, then you would add the following directories by using the Tools -> Options... pull-down menu and then selecting Projects and Solutions and in that selecting VC++ Directories and continuing on to enter the following:

Executable Files 
C:\Panda3D-1.7.0\bin
Include Files  
C:\Panda3D-1.7.0\python\include
C:\Panda3D-1.7.0\include
Library Files 
C:\Panda3D-1.7.0\python\libs
C:\Panda3D-1.7.0\lib

Note about VS2010: From Visual Studio 2010 onwards, Microsoft has removed global path settings, so you have to set these paths on a per project basis. In this case, in order to set the Executable path you should add it to the environment. You can do that on the Debugging section of your project properties. Set "merge environment" to yes and set environment to "PATH=C:\Panda3D-1.7.0\bin". Adding include and library paths is straightforward. Even if you don't use VS2010, it's not a bad idea to enter the settings this way since it's cleaner. The correct way of reusing settings across projects is through the use of Property Sheets (External link to MSDN). But also see the note about VS2010 above: if you are using 2010, you must build all of Panda from source; you cannot use the prebuilt DLL's provided for download.

Note about dependencies: Depending on what Panda features you use in C++ you may need to specify some extra paths, for example:

C:\Panda3D-1.7.0\thirdparty\win-libs-vc9\openssl\include
C:\Panda3D-1.7.0\thirdparty\win-libs-vc9\ode\include
C:\Panda3D-1.7.0\thirdparty\win-libs-vc9\freetype\include

You can get a package containing the thirdparty folder separately from the Panda3D website. The same goes for library paths.

Step three: Add libraries

After adding all these directories, right click on project and select properties. In the menu that comes up select the Linker and then the Input tab. In the Additional Dependencies row add the following libraries:

libp3framework.lib
libpanda.lib
libpandafx.lib
libpandaexpress.lib
libp3dtool.lib
libp3dtoolconfig.lib
libp3pystub.lib
libp3direct.lib

You may also need to add more libraries depending on the features you use.