[Insight-users] ITK wrapping: sharing symbols across shared modules

Zachary Pincus zpincus at stanford.edu
Fri Feb 17 09:20:45 EST 2006


Hi folks,

I've been really banging my head against an issue for a day now that  
I hope someone can help me with.

As some may recall, I'm working on updating the wrapper system for  
ITK. The code is split into several shared modules, so instances  
created in one module need to work across module boundaries. (So that  
images created by filters from one module can be used by filters from  
other modules.)

This means getting C++ RTTI and dynamic casting to work across shared  
module boundaries. Right now, for me, it's broken. I'm using OS X;  
Gaetan who is working with me on this is using Linux and I don't  
think RTTI is broken for him.

I'm hoping that some of the people who worked on the original  
wrappers, or who have a deeper understanding of C++ linking, have  
some recollection of how to un-break this. Now, I'm not sure whether  
I need to have CMake do anything special when linking these modules,  
or if I need to do anything fancy when trying to load them (right  
now, in Python).

For the record, cmake is linking the modules as follows:
/usr/bin/c++ -bundle -o [output].so [object files] -L[link paths] -l 
[link libs]

I'm loading the modules with Python which (I think) uses dlopen() to  
do this. Moreover, I've set python's dlopen flags (via sys.setdlopen 
()) to RTLD_NOW|RTLD_GLOBAL (as defined in dlfcn.h on my machine), so  
I think the module symbols are getting loaded globally and  
immediately. (Other variations on the flags don't help.)

Nevertheless (and perhaps global loading doesn't help with this),  
each module has its own RTTI information for each class and uses that  
information. I'm really not sure what to do here, so any thoughts at  
all would be very welcome.


Zach Pincus

Program in Biomedical Informatics and Department of Biochemistry
Stanford University School of Medicine



More information about the Insight-users mailing list