libdtoolutil and libdtoolbase both #include Python.h which adds certain symbols into their symbol table (see symbols below). When linking against standalone executables such as maya2egg these symbols are undefined. I had to manually edit the Makefile to add -lpython2.6 to each executable that pulled in one of these libraries. This gets very tricky for Maya because Maya (version 8.5 and later) was compiled against it’s own version of python. If you don’t compile panda against Maya’s python version you will get a segfault when trying to run maya2egg. Is there any possible way of splitting the parts of libdtoolutil and libdtoolbase that maya2egg relies upon into separate libraries that don’t rely on python?
objdump -t /disk1/scratch/panda/lib/libdtoolbase.so | grep Py
0000000000000000 UND 0000000000000000 PyObject_CallMethod
objdump -t /disk1/scratch/panda/lib/libdtoolutil.so | grep Py
0000000000000000 UND 0000000000000000 PySys_GetObject
0000000000000000 UND 0000000000000000 PyString_AsString
0000000000000000 UND 0000000000000000 PyList_GetItem
0000000000000000 UND 0000000000000000 PyObject_Type
0000000000000000 UND 0000000000000000 Py_BuildValue
0000000000000000 UND 0000000000000000 Py_IsInitialized
Normally we solve this linking problem by adding -lpystub to each standalone executable. libpystub.so is a special file of our own devising that simply stubs out the required Python references.
This is problematic in recent versions of Maya, which independently link with their own (different) version of Python. It’s a real mess. The only way I’ve found to build a reliable maya2egg with a recent version of Maya is to configure a special build of Panda without any Python dependencies. I guess it might also work to build Panda with precisely the same version of Python used by Maya.
I didn’t think the Python version was a problem until Maya 2009 or so, though. Did Maya version 8.5 link with Python too?
I’m not sure if 8.5 links with python or not. I only mentioned 8.5 because I know that was when the Python API was introduced, but I don’t know if it was compiled with it. I know for a fact that 2009 and 2010 both have this problem.
I’m trying to compile panda right now using Maya’s python version by setting PYTHON_IPATH and PYTHON_LPATH to point into $MAYA_LOCATION. I’ll also give the -lpystub a try to see if that solves my problem.
Linking against Maya’s version of python worked, but linking against libpystub didn’t.
Maya’s MLibrary::initialize appears to initialize the python interpreter, so if instead of finding the python library it was expecting it found the empty stub that is probably causing the crash.
The best approach is probably to build a version of panda without the python dependency and use that maya2egg.
Right, that’s the approach we have used.