[Python-Dev] Problems with Python's default dlopen flags

Martin v. Loewis martin@v.loewis.de
05 May 2002 23:50:21 +0200


Jack Jansen <Jack.Jansen@oratrix.com> writes:

>  From experience I can say this is not a good idea. MacOS extension
> modules used to do this until Python 1.5.2, and it can have undesired
> side effects (similar to the C++ initializer problems you noted). If
> you need to communicate symbols between module A and B it's better to
> make a normal shared library ABglue.so which contains the glue code,
> and link both A and B against it. 

I completely agree that this is the best thing to do, as it is most
portable. On Linux (and probably all other SysV ELF systems), you can
get away with linking against an extension module.

> The only question is where to put the ABglue.so file, on Mac and
> some (most?) unixen it's probably okay to drop it in lib-dynload,
> but it could be you need some fiddling of the flags that control the
> shared library search path for A and B.

On Unix, you'll need to set LD_LIBRARY_PATH, or put the library into a
directory where ld.so automatically searches for libraries; that is
a deployment problem.

> I think on Windows you're stuck with putting it in the system
> directory (at least, I assume that that's why PyWinTypes is there).

Not necessarily: Any directory on PATH will do, plus the directory
where the executable is (i.e. c:\python22). For some reason,
c:\python22\DLLs is also searched, although I'm not sure what magic
arranges that.

Regards,
Martin