[C++-sig] RTLD_GLOBAL cures my g++ + Boost.Python + cross module blues?

J. Michael Owen mikeowen at llnl.gov
Thu Apr 21 02:50:14 CEST 2005


I've recently come across a method to get my g++ compiled Boost.Python classes 
wrapped in different shared libraries to work (cross module class 
inheritance, dynamic_cast, etc.), and I thought I'd share this to see if it's 
useful to anyone else here, as well as see if anyone knows of any problems 
with this approach.

For completeness I'm using Python 2.3.4, g++ 3.4.1, and the last Boost release 
(1.32.0) on Linux x86.  When compiling with g++ I've been plagued by the 
cross library type_info problems described elsewhere 
(http://www.python.org/moin/boost.python/CrossExtensionModuleDependencies), 
but recently I discovered that if I force python's dlopen to use RTLD_GLOBAL 
then upon importing my extensions the different libraries resolve these 
type_info problems and everything starts working.  All I've done is issue the 
following python commands before importing any Boost.Python wrapped code:

import sys, dl
sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)

While this seems to have solved all of my current cross-library problems, I'm 
suspicious that it could be this simple.  Does anyone else here have any 
experience with these g++/Boost.Python/cross module issues?  Is there a 
reason the above might be a bad idea?

Mike.

-- 
 "Hey...where are the sunflower seeds?" |       J. Michael Owen         
        o_o /                           |       
        (")                             |       Email:  mikeowen at llnl.gov
       \/'\/                            |
____(__(,_,)_______________________________________________________________




More information about the Cplusplus-sig mailing list