[vtkusers] downcasting in python wrappers in VTK 4.2.2

Brad King brad.king at kitware.com
Tue Jul 1 11:21:43 EDT 2003


Justin,

> That fixed it!  Ok, so, because I'd like to know, what's the magic
> that's happening here?  And is this something that could be done in some
> sort of platform-specific part of the vtk import?  Thanks!

There is a bug in GCC versions after 2.95 that causes weak symbols (which
result from inline methods like GetClassName) to be merged incorrectly for
dlopen-ed shared libraries.  The virtual function tables end up pointing
at different places in different libraries, so run-time invocation of them
is incorrect.

The work-around is to tell dlopen to allow symbols to be shared across
multiple libraries using the RTLD_GLOBAL flag.  Tcl uses this flag by
default, but python does not.  The code I gave you enables that flag for
python.

I didn't write the VTK python packaging code, so I'm not sure where this
code should be added.  Please find __helper.py and add these lines to the
bottom:

import os
if os.name == 'posix':
  import dl
  sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)

Then remove the lines from your script and see if the problem persists.

Thanks,
-Brad




More information about the vtkusers mailing list