Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Weird ldd problem



On Sun, 18 Jul 2021, Chavdar Ivanov wrote:

The main difference is indeed

... (RPATH)              Library rpath:
[$ORIGIN/:$ORIGIN/../../lib/libast:$ORIGIN/cmds:$ORIGIN/../../lib/libdll]

I have to read more to understand it though...


$ORIGIN? That's yet another way to locate shared libraries. At run-time,
$ORIGIN is replaced with the pathname of the executable, and libraries
are searched for in the new path that results. Let's say you link a
program like this:

	cc -o foo foo.c -Wl,-rpath='$ORIGIN/../lib'

Then, if the executable is installed in /opt/X/bin, the search path
becomes `/opt/X/bin/../lib'. Typically used by large commercial programs
which the user could install into any location, and they don't want the
user to muck about adjusting paths in /etc/ld.so.conf or LD_LIBRARY_PATH.

Incidentally, NetBSD's ld.elf_so seems overly sensitive about this. I
always thought that $ORIGIN always expanded to an absolute path rather
than a relative one. At least, that's how it is on Linux and FreeBSD.

Have the linker experts look at this, then file a PR if warranted.

-RVP


Home | Main Index | Thread Index | Old Index