[Python-Dev] Extensions that depend on .so's on Solaris

Barry A. Warsaw barry@digicool.com
Thu, 1 Mar 2001 16:11:32 -0500


>>>>> "GW" == Greg Wilson <Greg.Wilson@baltimore.com> writes:

    GW> I'm working on Solaris, and have configured Python using
    GW> --with-cxx=g++.  I have a library "libenf.a", which depends on
    GW> several .so's (Eric Young's libeay and a couple of others).  I
    GW> can't modify the library, but I'd like to wrap it so that our
    GW> QA group can write scripts to test it.

    GW> My C module was pretty simple to put together.  However, when
    GW> I load it, Python (or someone) complains that the symbols that
    GW> I know are in "libeay.so" are missing.  It's on
    GW> LD_LIBRARY_PATH, and "nm" shows that the symbols really are
    GW> there.  So:

    | 1. Do I have to do something special to allow Python to load
    |    .so's that extensions depend on?  If so, what?

Greg, it's been a while since I've worked on Solaris, but here's what
I remember.  This is all circa Solaris 2.5/2.6.

LD_LIBRARY_PATH only helps the linker find dynamic libraries at
compile/link time.  It's equivalent to the compiler's -L option.  It
does /not/ help the dynamic linker (ld.so) find your libraries at
run-time.  For that, you need LD_RUN_PATH or the -R option.  I'm of
the opinion that if you are specifying -L to the compiler, you should
always also specify -R, and that using -L/-R is always better than
LD_LIBRARY_PATH/LD_RUN_PATH (because the former is done by the person
doing the install and the latter is a burden imposed on all your
users).

There's an easy way to tell if your .so's are going to give you
problems.  Run `ldd mymodule.so' and see what the linker shows for the
dependencies.  If ldd can't find a dependency, it'll tell you,
otherwise, it show you the path to the dependent .so files.  If ldd
has a problem, you'll have a problem when you try to import it.

IIRC, distutils had a problem in this regard a while back, but these
days it seems to Just Work for me on Linux.  However, Linux is
slightly different in that there's a file /etc/ld.so.conf that you can
use to specify additional directories for ld.so to search at run-time,
so it can be fixed "after the fact".

    GW> Instead of offering a beer for the first correct answer this
    GW> time, I promise to write it up and send it to Fred Drake for
    GW> inclusion in the 2.1 release notes :-).

Oh no you don't!  You don't get off that easily.  See you next
week. :)

-Barry