On 18/12/13 14:29, Daniel Pocock wrote:
> On 18/12/13 14:12, Sebastian Ramacher wrote:
>> On 2013-12-18 13:56:57, Daniel Pocock wrote:
>>> Package: python-ldap
>>> Version: 2.4.10-1
>>> Severity: important
>>>
>>> When trying to use python-ldap from an embedded python inside another
>>> application, I get errors such as this:
>>>
>>> Traceback (most recent call last):
>>>   File "/usr/lib/python2.7/dist-packages/ldap/__init__.py", line 22, in
>>> <module>
>>>     import _ldap
>>> ImportError: /usr/lib/python2.7/dist-packages/_ldap.so: undefined
>>> symbol: PyExc_SystemError
>>>
>>>
>>> Looking at _ldap.so with ldd, I notice it is not linked to Python:
>>>
>>>    ldd /usr/lib/python2.7/dist-packages/_ldap.so | grep py
>>>
>>> As a hack, I add an explicit
>>>
>>>    dlopen("libpython2.7.so", RTLD_LAZY |RTLD_GLOBAL);
>>>
>>> into my own code (a C++ app embedding Python) before Py_Initialize and
>>> then everything works nicely - but this is a hack and probably needs to
>>> be fixed by linking _ldap.so with -lpython2.7
>> No. Extensions modules do not link against libpythonX.Y in Debian.
>> Please check with Python Policy 2.1.
>>
>> It looks like the embedding application is built incorrectly.
> Is there any documentation on how such applications should be built/linked?
>
> I've found various discussion threads but many of them just contain
> things that look like hacks and that left me feeling that _ldap.so was
> not correct

The embedding application is slightly more complicated - it is actually
a modular application itself.  It does not link directly to Python,
rather one of its modules encapsulates an embedded Python.

The module is built using the values provided by python2.7-config as per
the manual:
http://docs.python.org/2/extending/embedding.html#compiling-and-linking-under-unix-like-systems

The high level application loads its modules with dlopen() - I've found
that adding RTLD_GLOBAL to that dlopen() call also provides a solution
but it is not clear whether this is a good idea as it would mean symbols
from all modules are exposed to all other modules.


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to