Help for running the hello world tutorial!

Hi all!

I have found a serious issue while trying to run the “hello world” application using C++ under Ubuntu Karmic Koala.

I have done the following:

First, I have installed the required .deb package for Ubuntu Karmic.

Then, I have created a file named “demo.cxx” with the following code:

#include "pandaFramework.h"
#include "pandaSystem.h"
 
PandaFramework framework;
 
int main(int argc, char *argv[]) {
    //open a new window framework
  framework.open_framework(argc, argv);
    //set the window title to My Panda3D Window
  framework.set_window_title("My Panda3D Window");
    //open the window
  WindowFramework *window = framework.open_window();
 
  //here is room for your own code
 
    //do the main loop, equal to run() in python
  framework.main_loop();
    //close the window framework
  framework.close_framework();
  return (0);
}

I have tried to compile this code using the following sentence in the command line:

g++ -c demo.cxx -o demo.o -fPIC -O2 -I/{usr/include/python2.6} -I{/usr/include/panda3d}

(I have checked it and the required libraries are there.)

However, after running this I get the following error:

demo.cxx:1:28: error: pandaFramework.h: No such file or directory
demo.cxx:2:25: error: pandaSystem.h: No such file or directory
demo.cxx:4: error: ‘PandaFramework’ does not name a type
demo.cxx: In function ‘int main(int, char**)’:
demo.cxx:8: error: ‘framework’ was not declared in this scope
demo.cxx:12: error: ‘WindowFramework’ was not declared in this scope
demo.cxx:12: error: ‘window’ was not declared in this scope

Any idea about how to fix this issue?

Many thanks for your help!

Clearly it’s not finding pandaFramework.h, which is the first of many Panda header files. Is that file to be found in /usr/include/panda3d?

David

Yes, I guess you are right!

I have tried to solve this changing the command to:

g++ -c demo.cxx -o demo.o -fPIC -O2 -I/usr/include/python2.5 -I/usr/include/panda3d

But this creates a even longer error list. I’m copying below just a few of the first lines:

In file included from /usr/include/panda3d/cycleData.h:19,
                 from /usr/include/panda3d/pandaNode.h:20,
                 from /usr/include/panda3d/nodePath.h:20,
                 from /usr/include/panda3d/windowFramework.h:19,
                 from /usr/include/panda3d/pandaFramework.h:20,
                 from demo.cxx:1:
/usr/include/panda3d/typeHandle.h:69:20: error: Python.h: No existe el fichero ó directorio
In file included from /usr/include/panda3d/cycleData.h:19,
                 from /usr/include/panda3d/pandaNode.h:20,
                 from /usr/include/panda3d/nodePath.h:20,
                 from /usr/include/panda3d/windowFramework.h:19,
                 from /usr/include/panda3d/pandaFramework.h:20,
                 from demo.cxx:1:
/usr/include/panda3d/typeHandle.h:106: error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/include/panda3d/typeHandle.h:106: error: expected ‘;’ before ‘*’ token
In file included from /usr/include/panda3d/dSearchPath.h:20,
                 from /usr/include/panda3d/configPageManager.h:20,
                 from /usr/include/panda3d/configVariableCore.h:20,
                 from /usr/include/panda3d/configVariableBase.h:20,
                 from /usr/include/panda3d/configVariable.h:19,
                 from /usr/include/panda3d/configVariableEnum.h:19,
                 from /usr/include/panda3d/notifyCategory.h:21,
                 from /usr/include/panda3d/notifyCategoryProxy.h:20,
                 from /usr/include/panda3d/config_express.h:19,
                 from /usr/include/panda3d/referenceCount.h:23,
                 from /usr/include/panda3d/nodeReferenceCount.h:20,
                 from /usr/include/panda3d/cycleData.h:20,
                 from /usr/include/panda3d/pandaNode.h:20,
                 from /usr/include/panda3d/nodePath.h:20,
                 from /usr/include/panda3d/windowFramework.h:19,
                 from /usr/include/panda3d/pandaFramework.h:20,
                 from demo.cxx:1:
/usr/include/panda3d/filename.h:70: error: ISO C++ forbids declaration of ‘PyObject’ with no type

I think that the issue it is caused because of python-dev not being installed but, since Ubuntu has Python installed by default and this package is not available in Synaptic, I can not imagine how to fix it.

Any ideas?

Ubuntu has python installed by default, but not python-dev. On my Ubuntu machine I can just ‘apt-get install python-dev’ and down it comes.

David

Exactly!!!

I just needed to use the command:

sudo apt-get install python-dev

…and after a while, I could compile the program with:

g++ -c demo.cxx -o demo.o -fPIC -O2 -I/usr/include/python2.6 -I/usr/include/panda3d

…convert it into a executable with:

g++ demo.o -o demo -fPIC -L/usr/lib/panda3d -lp3framework -lpanda -lpandafx -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3pystub -lp3direct

…and run it with:

./demo

It’s great! Thanks to all for your help!