[SOLVED] Maya exporter compiling problems

I think this is one that was actually answered years ago but I’ve forgotten how to fix it.

I’m compiling Panda (from CVS) on Linux (Kubuntu 12.04 64 bit).

Everything works fine except building maya2egg2011 and maya2egg2012 - there seems to be a linker problem with python.

Here is the error:

[T1] Linking executable built/bin/maya2egg2011
g++ -o built/bin/maya2egg2011 -Lbuilt/lib -Lbuilt/tmp -L/usr/X11R6/lib built/tmp/mayapath2011.o -lp3dtool -lp3dtoolconfig -lpandaexpress -pthread -ldl
built/lib/libpandaexpress.so: undefined reference to `PyExc_ValueError'
built/lib/libpandaexpress.so: undefined reference to `PyString_Size'
built/lib/libp3dtoolconfig.so: undefined reference to `PyObject_Call'
built/lib/libpandaexpress.so: undefined reference to `PyString_AsStringAndSize'
...

many other undefined references follow, all Python ones.

I get the same build errors with maya2egg2012.

Building with --no-maya2011 --no-maya2012 completes with no errors.

Just for the heck of it I tried this:

g++ -o built/bin/maya2egg2012 -Lbuilt/lib -Lbuilt/tmp -L/usr/X11R6/lib built/tmp/mayapath2012.o -lp3dtool -lp3dtoolconfig -lpandaexpress -pthread -ldl -lpython2.7

which completes with no errors.

However, then I got this odd error at runtime:

built/bin/maya2egg2012
MAYA_LOCATION: /usr/autodesk/maya2012-x64
Could not find $MAYA_LOCATION/bin/OpenMaya.so!

well of course not - the correct path is $MAYA_LOCATION/lib/libOpenMaya.so.

As an experiment I changed mayapath.cxx to look there instead:

static const Filename openmaya_filename = "lib/libOpenMaya.so";

that probably breaks Windows, but whatever :stuck_out_tongue:

Now, using the above g++ incantation, I got a compiled maya2egg2012 that doesn’t have trouble finding libOpenMaya, but unfortunately dies with an invalid pointer crash:

built/bin/maya2egg2012
MAYA_LOCATION: /usr/autodesk/maya2012-x64
*** glibc detected *** built/bin/maya2egg2012: free(): invalid pointer: 0x0000000001289f28 ***

Here’s the stack trace

(gdb) bt
#0  0x00007ffff2bb3445 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff2bb6bab in __GI_abort () at abort.c:91
#2  0x00007ffff2bf0e2e in __libc_message (do_abort=2, fmt=0x7ffff2cf90d0 "*** glibc detected *** %s: %s: 0x%s ***\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:201
#3  0x00007ffff2bfb626 in malloc_printerr (action=3, str=0x7ffff2cf6081 "free(): invalid pointer", ptr=<optimized out>) at malloc.c:5007
#4  0x00007ffff51ab280 in ConfigPageManager::reload_implicit_pages() () from /usr/lib/panda3d/libp3dtoolconfig.so.1.8
#5  0x00007ffff51a9828 in ConfigVariableCore::get_declaration(int) const () from /usr/lib/panda3d/libp3dtoolconfig.so.1.8
#6  0x00007ffff574077f in ConfigVariableBool::get_value() const () from /usr/lib/panda3d/libpandaexpress.so.1.8
#7  0x00007ffff572f053 in MemoryUsage::MemoryUsage(MemoryHook const&) () from /usr/lib/panda3d/libpandaexpress.so.1.8
#8  0x00007ffff572f5d4 in MemoryUsage::get_global_ptr() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#9  0x00007ffff5758a8b in VirtualFileMount::VirtualFileMount() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#10 0x00007ffff5752be7 in VirtualFileSystem::mount(Filename const&, Filename const&, int, std::string const&) () from /usr/lib/panda3d/libpandaexpress.so.1.8
#11 0x00007ffff5752fd5 in VirtualFileSystem::get_global_ptr() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#12 0x00007ffff56d1cd8 in VirtualFileMountHTTP::reload_vfs_mount_url() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#13 0x00007ffff56a8485 in init_libdownloader() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#14 0x00007ffff56a86e6 in __static_initialization_and_destruction_0(int, int) [clone .constprop.259] () from /usr/lib/panda3d/libpandaexpress.so.1.8
#15 0x00007ffff7de9306 in call_init (l=<optimized out>, argc=1, argv=0x7fffffffdef8, env=0x7fffffffdf08) at dl-init.c:85
#16 0x00007ffff7de93df in call_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=<optimized out>) at dl-init.c:52
#17 _dl_init (main_map=0x7ffff7ffe2c8, argc=1, argv=0x7fffffffdef8, env=0x7fffffffdf08) at dl-init.c:134
#18 0x00007ffff7ddb6ea in _dl_start_user () from /lib64/ld-linux-x86-64.so.2

After I get this working I get to do the whole process again for Maya 2013. Heeeelp!

That looks like a static init ordering issue. These are very hard to track down. Could you try recompiling with debugging symbols?

Sure - is there a way to set a debug flag in makepanda? I tried adding -g by hand to g++ commands to build and link maya2egg, but the backtrace didn’t give much more useful information so I think I need debugging symbols in libpandaexpress.

Adding --optimize 1 and deleting the “built” directory will generate a build with full debug symbols.

I did a fresh build with --optimize 1. Still having the same linker errors when it gets to maya2egg:

built/lib/libpandaexpress.so: undefined reference to `PyExc_ValueError' 
etc

so I built everything else using

makepanda/makepanda.py --everything --optimize 1 --no-fftw --no-maya-2011 --no-maya-2012 --verbose

and then built maya2egg:

g++ -ggdb -o built/bin/maya2egg2012 -Lbuilt/lib -Lbuilt/tmp -L/usr/X11R6/lib built/tmp/mayapath2012.o -lp3dtool -lp3dtoolconfig -lpandaexpress -pthread -ldl -lpython2.7

Question 1 is, obviously, “is tacking on -lpython2.7 the right thing to do … ?”

Anyway, results in gdb are not much different than before. The error happens right at the beginning of maya2egg2012_bin.


$ cd ~/panda/source/panda3d/built/bin
$ gdb maya2egg2012_bin
Reading symbols from /home/ben/panda/source/panda3d/built/bin/maya2egg2012_bin...done.

(gdb) break main
Breakpoint 1 at 0x46a84e: file pandatool/src/mayaprogs/mayaToEgg.cxx, line 333.

(gdb) run
Starting program: /home/ben/panda/source/panda3d/built/bin/maya2egg2012_bin 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
*** glibc detected *** /home/ben/panda/source/panda3d/built/bin/maya2egg2012_bin: free(): invalid pointer: 0x0000000000838158 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7e626)[0x7ffff2bfb626]
/usr/lib/panda3d/libp3dtoolconfig.so.1.8(_ZN17ConfigPageManager21reload_implicit_pagesEv+0x230)[0x7ffff51ab280]
/usr/lib/panda3d/libp3dtoolconfig.so.1.8(_ZNK18ConfigVariableCore15get_declarationEi+0x128)[0x7ffff51a9828]
/home/ben/panda/source/panda3d/built/bin/maya2egg2012_bin(_ZNK14ConfigVariable13get_bool_wordEi+0x61)[0x481a89]
/home/ben/panda/source/panda3d/built/bin/maya2egg2012_bin(_ZNK18ConfigVariableBool9get_valueEv+0x44)[0x481ea8]
/usr/lib/panda3d/libpandaexpress.so.1.8(_ZN11MemoryUsageC1ERK10MemoryHook+0x183)[0x7ffff572f053]
/usr/lib/panda3d/libpandaexpress.so.1.8(_ZN11MemoryUsage14get_global_ptrEv+0x64)[0x7ffff572f5d4]
/usr/lib/panda3d/libpandaexpress.so.1.8(_ZN16VirtualFileMountC2Ev+0x3b)[0x7ffff5758a8b]
/usr/lib/panda3d/libpandaexpress.so.1.8(_ZN17VirtualFileSystem5mountERK8FilenameS2_iRKSs+0x87)[0x7ffff5752be7]
/usr/lib/panda3d/libpandaexpress.so.1.8(_ZN17VirtualFileSystem14get_global_ptrEv+0xd5)[0x7ffff5752fd5]
/usr/lib/panda3d/libpandaexpress.so.1.8(_ZN20VirtualFileMountHTTP20reload_vfs_mount_urlEv+0x18)[0x7ffff56d1cd8]
/usr/lib/panda3d/libpandaexpress.so.1.8(_Z18init_libdownloaderv+0x35)[0x7ffff56a8485]
/usr/lib/panda3d/libpandaexpress.so.1.8(+0x9d6e6)[0x7ffff56a86e6]
/lib64/ld-linux-x86-64.so.2(+0xf306)[0x7ffff7de9306]
/lib64/ld-linux-x86-64.so.2(+0xf3df)[0x7ffff7de93df]
/lib64/ld-linux-x86-64.so.2(+0x16ea)[0x7ffff7ddb6ea]

(long memory map...)

Program received signal SIGABRT, Aborted.
0x00007ffff2bb3445 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.

(gdb) bt
#0  0x00007ffff2bb3445 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff2bb6bab in __GI_abort () at abort.c:91
#2  0x00007ffff2bf0e2e in __libc_message (do_abort=2, fmt=0x7ffff2cf90d0 "*** glibc detected *** %s: %s: 0x%s ***\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:201
#3  0x00007ffff2bfb626 in malloc_printerr (action=3, str=0x7ffff2cf6081 "free(): invalid pointer", ptr=<optimized out>) at malloc.c:5007
#4  0x00007ffff51ab280 in ConfigPageManager::reload_implicit_pages() () from /usr/lib/panda3d/libp3dtoolconfig.so.1.8
#5  0x00007ffff51a9828 in ConfigVariableCore::get_declaration(int) const () from /usr/lib/panda3d/libp3dtoolconfig.so.1.8
#6  0x0000000000481a89 in ConfigVariable::get_bool_word (this=0x7fffffffd490, n=0) at built/include/configVariable.I:223
#7  0x0000000000481ea8 in ConfigVariableBool::get_value (this=0x7fffffffd490) at built/include/configVariableBool.I:128
#8  0x00007ffff572f053 in MemoryUsage::MemoryUsage(MemoryHook const&) () from /usr/lib/panda3d/libpandaexpress.so.1.8
#9  0x00007ffff572f5d4 in MemoryUsage::get_global_ptr() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#10 0x00007ffff5758a8b in VirtualFileMount::VirtualFileMount() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#11 0x00007ffff5752be7 in VirtualFileSystem::mount(Filename const&, Filename const&, int, std::string const&) () from /usr/lib/panda3d/libpandaexpress.so.1.8
#12 0x00007ffff5752fd5 in VirtualFileSystem::get_global_ptr() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#13 0x00007ffff56d1cd8 in VirtualFileMountHTTP::reload_vfs_mount_url() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#14 0x00007ffff56a8485 in init_libdownloader() () from /usr/lib/panda3d/libpandaexpress.so.1.8
#15 0x00007ffff56a86e6 in __static_initialization_and_destruction_0(int, int) [clone .constprop.259] () from /usr/lib/panda3d/libpandaexpress.so.1.8
#16 0x00007ffff7de9306 in call_init (l=<optimized out>, argc=1, argv=0x7fffffffdf88, env=0x7fffffffdf98) at dl-init.c:85
#17 0x00007ffff7de93df in call_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=<optimized out>) at dl-init.c:52
#18 _dl_init (main_map=0x7ffff7ffe2c8, argc=1, argv=0x7fffffffdf88, env=0x7fffffffdf98) at dl-init.c:134
#19 0x00007ffff7ddb6ea in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#20 0x0000000000000001 in ?? ()
#21 0x00007fffffffe296 in ?? ()
#22 0x0000000000000000 in ?? ()

Some of the entries in the backtrace have line numbers now, but others don’t. Are you sure there isn’t still an old build in /usr/lib/panda3d ?

I don’t know if -lpython2.7 is the right thing to do. It sounds like it may be.

oh my, well, look at that, so there is. :blush:

Ok, that solved the segmentation fault. Exporter works fine now.

So the two steps I did for success were

  1. in mayapath.cxx, changed the OpenMaya path locations for linux:
#ifdef IS_OSX
static const Filename openmaya_filename = "MacOS/libOpenMaya.dylib";
#elif defined(IS_LINUX)
static const Filename openmaya_filename = "lib/libOpenMaya.so";
#else
static const Filename openmaya_filename = "bin/OpenMaya.so";
#endif  // IS_OSX

(is that third option for Windows? should it be OpenMaya.lib?)

  1. invoke makepanda with --everything, allow it to halt on linking maya2egg.
  2. manually link maya2egg, with -lpython2.7
  3. invoke makepanda with --no-maya2012, to build everything else

for testing, did

export LD_LIBRARY_PATH=built/lib

looks like that’s what tripped me up - it was loading an old libpandaexpress.so from /usr/lib.

thanks!