python-ldapをインストールしたら

python、というよりPloneからLDAPを使いたくてpython-ldapをインストール。いつもどおりインストールして試験してみると、ライブラリのシンボルが見えないとのエラー。

% python
>>> import ldap ;
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.4/site-packages/ldap/__init__.py", line 23, in ? from _ldap import *
ImportError: /usr/local/lib/python2.4/site-packages/_ldap.so: undefined symbol:ber_pvt_opt_on

OpenLDAPのライブラリが見えてないのかなと思い、LD_LIBRARY_PATHに/usr/local/libを追加しても同じ現象。いろいろ試した結果、open-ldapのソースをコンパイルするときのsetup.cfgに手を入れて再インストールして解決。

デフォルトのsetup.cfgはこんなの。

# Section for compiling the C extension module
# for wrapping OpenLDAP 2 libs
[_ldap]

library_dirs = /usr/local/openldap-2.3/lib
include_dirs = /usr/local/openldap-2.3/include /usr/include/sasl
(以下略)

これのlibrary_dirsに/usr/local/libを追加。

# Section for compiling the C extension module
# for wrapping OpenLDAP 2 libs
[_ldap]

library_dirs = /usr/local/openldap-2.3/lib /usr/local/lib
include_dirs = /usr/local/openldap-2.3/include /usr/include/sasl

これで再度インストール。