Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108538

Re: Finding .so files without setting LD_LIBRARY_PATH

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From eryk sun <eryksun@gmail.com>
Newsgroups comp.lang.python
Subject Re: Finding .so files without setting LD_LIBRARY_PATH
Date Thu, 12 May 2016 03:08:43 +0100
Lines 35
Message-ID <mailman.602.1463018971.32212.python-list@python.org> (permalink)
References <1463002764.2579.26.camel@mad-scientist.net> <CACL+1at7pLfZ2bMe5FK6GT=GUFq18roqG14t+tV_TXQWftucBA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de bADFhgxNO7XRnd7tRNmEkApJD/+nrf13YCbSluJSNCqw==
Return-Path <eryksun@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'resulting': 0.04; 'paths': 0.05; 'tries': 0.05; 'grep': 0.09; 'runtime': 0.09; 'subject:files': 0.09; 'subject:setting': 0.09; 'python': 0.10; 'wed,': 0.15; '2016': 0.16; 'dlopen': 0.16; 'elf': 0.16; 'gnu/linux.': 0.16; 'header:': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'passes': 0.18; 'pfxlen:0': 0.18; 'skip:l 30': 0.18; 'ssl': 0.18; 'load': 0.20; 'library': 0.20; 'versions': 0.20; 'cc:2**0': 0.20; 'libraries': 0.22; 'object.': 0.22; 'subject: .': 0.22; 'defined': 0.23; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'header': 0.24; 'paul': 0.24; 'module': 0.25; 'example': 0.26; 'linux': 0.26; '(e.g.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'loads': 0.29; 'searches': 0.29; 'environment': 0.29; "i'm": 0.30; 'relative': 0.30; 'skip:[ 10': 0.31; "i'd": 0.31; 'extend': 0.31; 'embedded': 0.32; 'loading': 0.33; '(for': 0.34; 'running': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'path': 0.35; 'instead': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'setting': 0.37; 'received:209.85.213': 0.37; 'version': 0.38; 'received:209': 0.38; 'files': 0.38; 'copying': 0.38; 'shared': 0.38; 'build': 0.40; 'to:addr:python.org': 0.40; 'different': 0.63; 'children.': 0.76; 'smith': 0.76; './configure': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vt+8BXlBIYrl3nb+HYMjvr38pcSJtJm3iLj9tlPJRUk=; b=bN1uNB0ODZS/cyO5j+r4aFbE3dfm5cZo9vVg3Pf7BdeoN2JCU15Uto7KpFCpeqlCme WJlPFYR8FjDEGl8lNkB6o0dYKM33TYWPCQrpNEFeengF3/3czQri7XOfOy09LS5qrJNw 3o+1B63Z1Wvkr/QPAD9i/vv8ZOVYZHsICTeCGo17SmC0/jib8pHokKD6XNW+so4ey1i8 yBQWxItYW7Tfxc2crbPBcgV+ATwuLqRvvaoSmSKIxI2gQ4W+Xk8w8H9hZ5RyMLgaG9rQ zdZ/XSTiJ+5OVJy9HtHThyvjKY592SOgvgZopsiAc3zFkbIh/FO+cPLoaOczN6Kgy0lk w8Hg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vt+8BXlBIYrl3nb+HYMjvr38pcSJtJm3iLj9tlPJRUk=; b=OxR+ffobwwsW2SQqAaKvVG7U95ezRkvEpAGePVcz4uG9gXYCqzZ7b15LYum0GQZMcn I2xaqT/MAN4771rFwcO4m5QYrpNs6eiga+6chnvqP1cRSZU2Z/B2NeFoYpxBmNpFb/Wg zHeb/FbKkGnN7Y5+IGfXQQEmzNvojyMPq/yppV5jT5U0mhwMJhatfk2UcksSQJ7FeN1P lJfB5We9POexbmz5ktqd0cbBqGOd6QVpLwgsRyRMr8sq+gGvQNUM25X6au8ndRkFimE7 CcifnfuIdMoEttYNGx+MwIuWWepZIhY61EhgXydEijXNzNnzblrBhsHgAcgFox9oDEoS ydbQ==
X-Gm-Message-State AOPr4FVo/tm+nExWJR7IAyWYkiv3RSDYUQMTR+6Ry+ez7ip4nwQGHxTvG+0cRBd6G3/QkhzgaKPr0TNerLkC2g==
X-Received by 10.50.9.132 with SMTP id z4mr24543156iga.74.1463018962974; Wed, 11 May 2016 19:09:22 -0700 (PDT)
In-Reply-To <1463002764.2579.26.camel@mad-scientist.net>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CACL+1at7pLfZ2bMe5FK6GT=GUFq18roqG14t+tV_TXQWftucBA@mail.gmail.com>
X-Mailman-Original-References <1463002764.2579.26.camel@mad-scientist.net>
Xref csiph.com comp.lang.python:108538

Show key headers only | View raw


On Wed, May 11, 2016 at 10:39 PM, Paul Smith <paul@mad-scientist.net> wrote:
> Hi all.  I have a locally-built version of Python (2.7.11) that I'm
> copying around to different systems, running all different versions of
> GNU/Linux.
...
> What I'd like to do is have a way of setting the library path that
> Python uses when it tries to load .so files (for example in the ssl
> module which loads lib-dynload/_ssl.so which links to libssl.so and
> libcrypto.so), WITHOUT setting LD_LIBRARY_PATH in the environment that
> Python passes to its children.

An ELF header can contain either an RPATH or a RUNPATH to extend the
library search path at load time. RPATH is searched before
LD_LIBRARY_PATH, while RUNPATH is searched after LD_LIBRARY_PATH. Note
that the Linux loader only uses an embedded RUNPATH when searching for
the immediate dependencies of an object. Use an RPATH instead if you
need to extend the path that dlopen searches at runtime (e.g. for
loading shared libraries via ctypes).

Paths can be defined relative to the object using ${ORIGIN}. For
example, the following configures a Python build to add a relative
RPATH:

    $ ./configure LDFLAGS='-Wl,-rpath,\$${ORIGIN}/lib'
    $ make

Or a RUNPATH:

    $ ./configure LDFLAGS='-Wl,-rpath,\$${ORIGIN}/lib,--enable-new-dtags'
    $ make

Here's the resulting RPATH in the ELF header:

    $ readelf -d python | grep RPATH
     0x000000000000000f (RPATH)              Library rpath: [${ORIGIN}/lib]

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Finding .so files without setting LD_LIBRARY_PATH eryk sun <eryksun@gmail.com> - 2016-05-12 03:08 +0100
  Re: Finding .so files without setting LD_LIBRARY_PATH Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-12 07:55 +0300
    Re: Finding .so files without setting LD_LIBRARY_PATH Paul Smith <paul@mad-scientist.net> - 2016-05-12 11:34 -0400

csiph-web