Panda3D Manual: Using Microsoft Visual Studio
   top      

Note: This page may be outdated. A new version of Panda3D has been released since this page was written which fully compiles now with VC8.


Microsoft Visual Studio is a well-known programming environment and compiler. It is possible to create C++ Panda3D projects using Microsoft Visual Studio, but it's not easy to setup everything. On this page will be explained how to compile pview, a Panda3D application which is shipped with Panda3D by default.

Assuming that $PANDADIR refers to the unpacked archive, pview can be found in the directory $PANDADIR/panda/src/testbed.

You must choose the include and libraries directories according to your compiler. For example under Windows with VisualStudio :

Include dirs

 $PANDADIR\include
 $PANDADIR\thirdparty\win-python\include
 $PANDADIR\thirdparty\win-libs-vc7\nspr\include

Library directories

 $PANDADIR\lib
 $PANDADIR\thirdparty\win-libs-vc7\nspr\lib
 $PANDADIR\thirdparty\win-python\libs

If you don't have the thirdparty files, you can download them from the Downloads section.

With VisualStudio 8, these additional preprocessors definitions are needed : WIN32;NDEBUG;_CONSOLE;WIN32_VC (Note: Some users reported that, if NDEBUG doesn't work, you should try _DEBUG instead.)

A complete VS8 project can be found here. The archive has to be unzipped to $PANDADIR/samples/

Tutorial

(This tutorial was made by aaronbstjohn.)

You should now have everything you need to get started.

  • Launch Visual Studio and start a new project.
I made my project a standard win32 console application and started an "empty project".
  • Add pview.cxx to your project
I just copied it to my project folder and then added it to the project the usual way.
  • Setup your path
You can do this in your project properties for each panda project:
For include files go to:
Project>Properties>C++>General>Additional Include Directories
and add: "C:\Panda3D-1.3.2\include"
and "C:\Panda3D-1.3.2\thirdparty\win-libs-vc7\nspr\include"
and "C:\Panda3D-1.3.2\thirdparty\win-python\include"
For libs go to:
Project>Properties>Linker>General>Additional Library Directories
add "C:\Panda3D-1.3.2\lib"
and "C:\Panda3D-1.3.2\thirdparty\win-libs-vc7\nspr\lib"
and "C:\Panda3D-1.3.2\thirdparty\win-python\libs"
or if you're lazy (I am) put it in your global VS environment path.
Go To: Tools>Options>Projects>VC++ Directories
add the above paths to your Include and Library Directories respectively
  • Link to the panda libraries:
under:
Project>Properties>Linker>Input
add:
libpanda.lib libpandaexpress.lib libframework.lib libdtool.lib :libdtoolconfig.lib
  • Compile & Run, you're DONE !
Just kidding, you're not done, but you should try it to see what happens. This is how far I got before things got tricky.
Note: I'm compiling in Debug mode by default. Everything below should also work for Release mode. I was able to do both.


Error #1 : Python Debug Library issues

"LINK : fatal error LNK1104: cannot open file 'python24_d.lib'"

Problem: Panda doesn't come w/the debug lib for python. Neither does the regular python distribution. As far as I can tell you have to go compile all of python in debug mode for the privilege of debugging into python. Not something I cared to do.

Solution: Link agains the release version of Python instead of the debug version.

Go to: Project>Properties>Linker>Input and add "python24_d.lib" to your "Ignore Specific Library" section.

Then add "python24.lib" to your list of "Additional Dependencies"

Kiss your option of debugging into python good bye!


Error #2: Angry Linker

Linking...
pview.obj : error LNK2001: unresolved external symbol "void * (__cdecl* global_operator_new)(unsigned int)"
(?global_operator_new@@3P6APAXI@ZA)
pview.obj : error LNK2001: unresolved external symbol "void (__cdecl* global_operator_delete)(void *)"
(?global_operator_delete@@3P6AXPAX@ZA)
pview.obj : error LNK2001: unresolved external symbol _gnu_optind
pview.obj : error LNK2001: unresolved external symbol _gnu_optarg

etc...

Problem: Who knows (most likely internal panda stuff)

Solution: Add the preproccesor flag "WIN32_VC" Go to: Project>Properties>C/C++/Preprocessor and add WIN32_VC to your list of preprocessor directives.

For me this line looks like: WIN32;_DEBUG;_CONSOLE;WIN32_VC

If the error is still not fixed, try replacing _DEBUG with NDEBUG.

Error #3: Angry Linker Part 2

Linking...
libcpd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg
referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)"
(??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) libcpd.lib(_tolower.obj) : error LNK2001: unresolved external symbol __malloc_dbg
libcpd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg
referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)"
(??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)

Problem: Panda apps need to be multithreaded

Solution: Go to: Project>Properties>C/C++>Code Generation and change "Runtime Library" from "Single-threaded (/ML)" to "Multi-threaded DLL (/MD)"

  • Compile & Run, you're DONE FOR REAL!!!

No Really, you're done. At this point you should have the basic pview app compiled and running in VS using only the libs that come w/the standard panda install and the third party libs provided on the panda site. You should now be able to use pview as a jumping off point for developing full C++ only panda apps using Visual Studio.

   top