Trying to get it to work with c++

I don’t have a lib folder here in my installation, so I tried to run makepanda fully.

This is the error I get, using newest version from CVS, and both python 2.4 and 2.5 installed.

...
g++ -o built/bin/dcparse -Lbuilt/lib -L/usr/X11R6/lib built/tmp/dcparse_dcparse.o -lp3direct -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3pystub -Lthirdparty/linux-libs-a/nspr/lib -lpandanspr4
built/lib/libp3direct.so: undefined reference to `PyLong_FromLong'
built/lib/libp3direct.so: undefined reference to `PyObject_CallMethodObjArgs'
collect2: ld returned 1 exit status
Storing dependency cache.
Elapsed Time: 1 hours 0 min

Two versions of Python installed? Which one are you using? You have to be sure that you pick just one version, and use that one version in both the header files and in the libraries. If there’s any danger of mixing header files from one version and libraries from another, you might get errors such as this.

David

I removed version 2.5 – same problem. :cry:

Hmm. I’m not sure why you’re getting this error and I’m not, but try picking up the latest dtool/src/pystub (I just checked in some changes there) and try again.

David

Yes, I see you made a change 116 secs ago ( 8) I just love CVS)
This works!!! Thanks a lot David.

Now, when compiling the next one, it couldn’t find python.h
The problem is, It links to python2.5, which I removed already.
Now, when I try to change built/tmp/pythonversion to python2.4 makepanda keeps changing it back to python2.5…
Do I need to call makepanda whole over again, or can I change the version some other way?

EDIT: FIXED! I looked in the makepanda.py script and I saw it looked whether the directories /usr/include/python2.5 exist, i looked there and saw an empty directory. So I removed that one, and now it works fine.

OK, makepanda is done. Well… I think it was.
It gave no error, just said “storing dependency cache” and stopped. Is it done now? There’s still a folder /built/tmp. what to do with it?

I’ll see if I succeed now to build pview from scratch.

Ahrgh. I copied all the files successfully from the /built/bin dir to /usr/bin, /built/include to /usr/include/panda3d etc. etc. etc.

Now, I get even more errors when compiling pview. Mostly like:

I’m afraid I don’t call the compiler the right way. I call gcc like this:

Is this right?

One of the things that makepanda would have built is pview. Did it build that successfully? If so, why don’t you invoke the compiler the same way makepanda did to build pview?

David

David, I thank you so much!!! You made it work!!!

Just one thing before I start programming, I don’t really understand the g++ call from the makepanda script. I understand the -L and -I, but the rest… This one:

g++ -ftemplate-depth-30 -fPIC -c -o pview.o -I"/usr/include/python2.4" -Ithirdparty/linux-libs-a/nspr/include -Ibuilt/tmp -Ipanda/src/testbed -Ibuilt/include -O2 pview.cxx

Can you maybe explain it to me?

The “-c” means compile a source file into an object file (in this case the source file at the end of the line is pview.cxx, the -c could have gone right before this)

The “-o” specifies the output file, in this case pview.o, and object file that will later be linked with other object files to form the final executable.

“-02” specifies optimation level for the executable, 02 is fairly highly optimized (and 01 would be less optimized, etc., most of the time you don’t see higher than 02 and occasionally 03). Sometimes optimization is avoided if an executable needs to be debugged, because optimization tends to reorder parts of code and strip debugging information (not sure of gcc specifics here)

The “-f” flags are specific compiler directives, in this case telling it that C++ templates cannot be nested deeper than 30 (which would be pretty ridiculous anyways, this flag is probably unnecessary), and PIC for telling it the the object file should be compiled in a way such that it can be loaded into different locations in memory (i.e., a shared library, or DLL on Windows).

Thank you very much, Arkaein and David.

It works now, for one thing. I think this is Panda3D-source-related.

When I try to run pview - either the one compiled myself or the one compiled by makepanda, it gives me this error:

pview: symbol lookup error: pview: undefined symbol: _ZN17NodePathComponent5CData12_type_handleE

Which means, I can’t run pview at all.
Is this a bug? I downloaded the latest version from CVS.

I succeeded to write my own C++/panda game to open a window!!! wow! :wink:
That works anyway. So this bug would probably be a bug in pview.

Ty again Arkaein and David for all your help! I’m gonna write some docs tomorrow.