From: Ricardo Wurmus <rekado@elephly.net>
To: Pierre Neidhardt <ambrevar@gmail.com>
Cc: help-guix <help-guix@gnu.org>
Subject: Re: LIBRARY_PATH and foreign binaries: error while loading shared libraries
Date: Wed, 18 Apr 2018 22:39:04 +0200 [thread overview]
Message-ID: <87in8odzbr.fsf@elephly.net> (raw)
In-Reply-To: <87bmeh59yq.fsf@gmail.com>
Hi Pierre,
>> /path/to/foreign/binary
> /path/to/foreign/binary: No such file or directory
>
> This is because the path to the linker is wrong:
>
>> file /path/to/foreign/binary
> /path/to/foreign/binary: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=edf4cff78e6710ff4f7ac14cb99b38aefed2659e, stripped
>
> I can fix it with
>
>> patchelf --set-interpreter "$(realpath "$(which sh)")" /path/to/foreign/binary
>
> (Is this the commended way?)
It is one way that ensures that the correct linker is used. Another way
is to install the glibc’s dynamic linker in the expected location at
/lib64/ld-linux-x86-64.so.2.
> The "missing" libraries are indeed in my ~/.guix-profile/lib. This
> folder is properly referenced in the environment:
>
>> env | grep LIBRARY_PATH
> LIBRARY_PATH=/home/ambrevar/.guix-profile/lib
> My understanding is that the LIBRARY_PATH is only used for compiling,
Correct. It is respected by the linker.
> not at runtime. But then how come some libraries are found and not
> others?
That’s probably because the libraries it found end up there because of
patching the interpreter.
> If I export LD_LIBRARY_PATH to the value of LIBRARY_PATH, then it works:
>
>> export LD_LIBRARY_PATH=$LIBRARY_PATH
>> /path/to/foreign/binary
>
> Is there a better way?
The best way is to build the software from source. Short of that you
can load individual libraries with LD_PRELOAD. The most coarse-grain
solution is to use LD_LIBRARY_PATH.
--
Ricardo
next prev parent reply other threads:[~2018-04-18 20:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 6:01 LIBRARY_PATH and foreign binaries: error while loading shared libraries Pierre Neidhardt
2018-04-18 8:49 ` Pierre Neidhardt
2018-04-18 20:39 ` Ricardo Wurmus [this message]
2018-04-19 3:21 ` Pierre Neidhardt
2018-04-19 3:25 ` Pierre Neidhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87in8odzbr.fsf@elephly.net \
--to=rekado@elephly.net \
--cc=ambrevar@gmail.com \
--cc=help-guix@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.