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

Return to C++ coding using Panda3D

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

Postby Amnu » Thu Aug 13, 2009 3:57 am

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/wiki/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.

Code: Select all
#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
Amnu
 
Posts: 32
Joined: Tue Aug 04, 2009 6:11 am

Postby drwr » Thu Aug 13, 2009 8:38 am

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

David
drwr
 
Posts: 11425
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Amnu » Thu Aug 13, 2009 8:46 am

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
Code: Select all
#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 ?
Amnu
 
Posts: 32
Joined: Tue Aug 04, 2009 6:11 am

Postby drwr » Thu Aug 13, 2009 9:29 am

drwr
 
Posts: 11425
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Amnu » Thu Aug 13, 2009 9:53 am

That's exactly what I need and what I did not see. Thank you !
Amnu
 
Posts: 32
Joined: Tue Aug 04, 2009 6:11 am

Postby Amnu » Mon Aug 24, 2009 4:29 am

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

Code: Select all
framework.close_framework();


which will result in

Code: Select all
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.
Amnu
 
Posts: 32
Joined: Tue Aug 04, 2009 6:11 am

Postby Zorbatron » Mon Aug 24, 2009 10:38 am

Could you post the entire code?
Zorbatron
 
Posts: 28
Joined: Sat Aug 08, 2009 4:59 pm

Postby Amnu » Tue Aug 25, 2009 4:39 am

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

Code: Select all
#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

Code: Select all
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

Code: Select all
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 ...
Amnu
 
Posts: 32
Joined: Tue Aug 04, 2009 6:11 am

Postby drwr » Tue Aug 25, 2009 10:53 am

Hmm, how about if you replace it with:
Code: Select all
PandaFramework &framework = *(new PandaFramework);

?

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

David
drwr
 
Posts: 11425
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Amnu » Wed Aug 26, 2009 5:23 am

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

Code: Select all
#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

Code: Select all
//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.
:?:

EDIT:
While having

Code: Select all
PandaFramework &framework = *(new PandaFramework);


active I get a heap corruption no matter what I do after. There appears to be something very wrong.
Amnu
 
Posts: 32
Joined: Tue Aug 04, 2009 6:11 am

Postby Amnu » Wed Aug 26, 2009 6:46 am

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.
Amnu
 
Posts: 32
Joined: Tue Aug 04, 2009 6:11 am


Return to C++ coding using Panda3D

Who is online

Users browsing this forum: No registered users and 1 guest

cron