Once again, getting Panda 3D working with C++


#1

I’m trying to get to know Panda’s C++ API by working through the manual and maybe playing around with some small programs. I stumble over the first lines of code though …

When trying to compile the basic app as shown in the manual http://www.panda3d.org/manual/index.php/Starting_Panda3D I get so many errors that I do doubt my Panda 3D version is installed propperly. Since my programs work just fine with python I must have set something up quite wrong.

#include "pandaFramework.h"

int main(int argc, char *argv[])
{
 return 0;
}

gets me all kind of errors starting with

error C2059: syntax error : ‘enum [tag]’ c:\panda3d-1.6.2\include\parser-inc\iostream line32

Did I use the wrong include paths so the wrong files get included resulting in confusion ? If so which are the correct ones ? All I did was include “%PandaPath%/include” and “%PandaPath%/include/parser-inc”.

Thanks in advance,
Amnu


#2

Don’t include parser-inc. That’s not real code in there; it’s for interrogate only.

David


#3

Well I included that direcoty because the compiler was looking for Python.h and I didnt know any better then to search for it in Panda’s sources, found it there and included it. From what place shall I pull that one in then ?

Edit:
Nevermind me … I didn’t see I had to set -I%PANDADIR%/python/include as well … Wouldn’t hurt to mention that though. I wonder, since the include directive says

#include <Python.h>

shouldn’t those paths, meaning

%PANDADIR%/include and
%PANDADIR%/python/include

be set as additional system include paths by Panda’s installer ?

Edit2:
Well, I got it compiled now but the linker wishes to find python25.lib which it of course cannot find w/o pointing him the directions. There is such a file in

%PANDADIR/python/libs

but if I point him there I get 4 pretty ugly looking error messages about unresolved external symbols. Looks like some lib link is missing that I do not know of. Did I miss some Tutorial on doing this ? I can’t find any hints about setting this up in the manual or am I blind ?


#4

Did you see How to build a CXX Panda3D game using Microsoft Visual Studio 2008?

David


#5

That’s exactly what I need and what I did not see. Thank you !


#6

The program itself is running now (only gray empty screen) but once I try to close it, it crashes. I tracked down the problem to

framework.close_framework();

which will result in

Unhandled exception at 0x00c0fba7 in TestProject C++ with PhysX.exe: 0xC0000005: Access violation writing location 0x0000000a.

Since I am doing nothing but opening the window, running the (empty) main loop and then closing it again, I can’t see a reason as to why it is crashing.


#7

Could you post the entire code?


#8

I set up a new project, created a main.cpp and copied this from the manual

#include "pandaFramework.h"
#include "pandaSystem.h"

PandaFramework framework;
 
int main(int argc, char *argv[])
{
  framework.open_framework(argc, argv);
  framework.set_window_title("My Panda3D Window");
  WindowFramework *window = framework.open_window();
  framework.main_loop();
  framework.close_framework();
  return (0);
}

which will result in

Unhandled exception at 0x004ca6ac in Simulation.exe: 0xC0000005: Access violation writing location 0x000fffff.

upon closing. The exception occurs when returning from main.

Edit:
The problem appears to be with

PandaFramework framework;

since it by itself (meaning no other code active) will generate the exception. I was guessing the runtime wants to see it destroyed before terminating the application, since it is/might be considered an unmanaged application, but the destructor for that class is virtual …


#9

Hmm, how about if you replace it with:

PandaFramework &framework = *(new PandaFramework);

?

Which version of Panda are you using–is this 1.6.2?

David


#10

I am using Panda 1.6.2 (judging by directory name and version information in Windows’ software manager).

Concerning the change of code you suggested, well it’s strange enough… The program

#include "pandaFramework.h"
#include "pandaSystem.h"

PandaFramework &framework = *(new PandaFramework);
 
int main(int argc, char *argv[])
{
  framework.open_framework(argc, argv);
  //framework.set_window_title("My Panda3D Window");
  WindowFramework *window = framework.open_window();
  framework.main_loop();
  framework.close_framework();
  return (0);
}

does run and close without any errors. Yet removing the comment on

//framework.set_window_title("My Panda3D Window");

will cause a heap corruption. I hope this somewhat makes sense to you because it sure does not do so to me.
:question:

EDIT:
While having

PandaFramework &framework = *(new PandaFramework);

active I get a heap corruption no matter what I do after. There appears to be something very wrong.


#11

Well, all my fault. I must have overseen the big warning saying I need VS2008 for getting all this running (under Windows that is).

Well, it’s working now. The heap corruption was a result of cross library calls between msvc8 and msvc9 dlls.