[C++-sig] dll?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Thu May 23 19:55:42 CEST 2002


--- Robert Andre <randre at pppl.gov> wrote:
> 
> What was the final conclusion to the dll thread which suggested using
> 
>   import sys
>   sys.setdlopenflags(0x100|0x2)
> 
> to force sharing of symbols between extension modules?  I was quite 
> appreciative of this since it fixed the two problems that I was having with 
> boost python on linux/gcc 3.0.4.  The first problem was the loss of exception
> 
> type information which was mentioned in the thread.  The other problem I had 
> with a segfault deep in the stringstream class when using multiple dynamic 
> libraries has also disappeared.  I tend to use a small wrapper python class 
> where I put doctest documentation so I don't require the capability of
> forcing
> this flag from within the C++ extension module.  If boost python acquires the
> 
> feature of including docstrings then I would have less of a reason to have a 
> wrapper class other then for setting the dlopen flags.

Currently my conclusion is to keep using the dlopenflags for the time being
(Linux only). There have been long discussions about this in several forums
(gcc, c++ standardization reflector) and I am hopeful that in a few years we
can do without the dlopenflags :-)

FWIW: All our extensions are part of packages. As you know, a Python package
must have a __init__.py file. If you set the dlopenflags in the __init__.py
files you can be sure that the dlopenflags are set before the C++ extension is
imported. Here is what we use:

% cat __init__.py

import sys
if (sys.platform == "linux2"):
  if (hasattr(sys, "setdlopenflags")):
    sys.setdlopenflags(0x100|0x2)

Unfortunately the dlopenflags are set globally. Potentially this could lead to
name clashes when subsequently importing "C" extension modules. For us this
does not present a problem, but one should keep this in mind.

Ralf


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com





More information about the Cplusplus-sig mailing list