[m-users.] Installed library not found
Peter Wang
novalazy at gmail.com
Wed Sep 14 11:28:10 AEST 2022
On Tue, 13 Sep 2022 13:47:59 +0200 Volker Wysk <post at volker-wysk.de> wrote:
> Am Dienstag, dem 13.09.2022 um 21:28 +1000 schrieb Zoltan Somogyi:
> > 2022-09-13 20:48 GMT+10:00 "Volker Wysk" <post at volker-wysk.de>:
> > > desktop ~/src/tt $ ./tt
> > > ./tt: error while loading shared libraries: libposix.so: cannot open shared
> > > object file: No such file or directory
> > >
> > > The installed library is here:
> > >
> > > /usr/local/lib/mercury-srcdist-rotd-2022-09-
> > > 07/lib/mercury/lib/asm_fast.par.gc.stseg/libposix.so
> > >
> > > When I put the above path (the directory part of it) in the LD_LIBRARY_PATH
> > > variable, the program starts okay.
> >
> > What you have is a mismatch between
> >
> > - where the installed shared object is, and
> > - where the system looks for it.
> >
> > You can fix this either
> >
> > - by putting the shared object where the system expects it, or
> > - by telling to system to expect it where it is.
> >
> > You did the latter by including that directory in LD_LIBRARY_PATH.
> > You can also do it by installing the shared object into a directory
> > that is already in your LD_LIBRARY_PATH. Section 6.2.1 of the
> > user guide will tell you how.
>
> I've installed the library the standard way, "mmc -j8 --make
> libposix.install". I think this should work out of the box, if possible.
>
> The problem is, that the grade is part of the install path:
> /usr/local/lib/mercury-.../lib/asm_fast.par.gc.stseg/libposix.so
>
> The Posix library in question got installed in only one grade
> (asm_fast.par.gc.stseg), and I'm not sure why. If it were installed in
> several grades, the dynamic linker would need to be told somehow, which
> grade (hence, which directory) to look in. It would (right?) not be possible
> to add all grades to the LD_LIBRARY_PATH variable, because the differently
> compiled .so files, which have the same file name, would come into conflict
> with each other, wouldn't they?
>
> If I installed a library in some already existing place, I would get the
> problem with the different grades again.
To complete the picture, there is an optional variable in the binary
called the RPATH or RUNPATH which lists locations where the loader will
search for dynamically linked libraries (in addition to the default
locations and LD_LIBRARY_PATH). You can see it using "objdump -p".
When you linked the posix library using "--ml" the RPATH was set
automatically, that's why it started working. Whether you want the RPATH
to be set depends on what the binary is intended for. You can turn it
off with --no-default-runtime-library-directory.
Peter
More information about the users
mailing list