[Rd] Re: [R] LD_LIBRARY_PATH is harmfull

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Feb 21 10:19:09 CET 2005


Please use R-devel for comments about R development (moved there).

On Mon, 21 Feb 2005, Alexander Klimov wrote:

> Hi.
>
> Consider the following situation: Solaris 8, /usr/local has gcc 2.95,
> my home has gcc 3.4.3, my gcc is first on PATH, LD_LIBRARY_PATH is
> unset (everything is perfect since I always use -R). In fact, programs
> compiled with my gcc do not work if LD_LIBRARY_PATH is set to
> something which has /usr/local/lib before home/lib, because it
> overrides stored path (-R) and I got
>
>   libgcc_s.so.1 (GCC_3.3) =>       (version not found)

I don't believe that happens unless `home/lib' is not in the library paths 
at all.  I've checked man ld and man ld.so.1 on Solaris 8, and neither 
appear to mention that -R is ignored if LD_LIBRARY_PATH is set.  I think 
that is a (well-buried) Solaris-specific gotcha.

> I found setting of LD_LIBRARY_PATH in bin/R (how /usr/local/lib get
> into it at all and especially before PREFIX/lib??? -- there was no
> LD_LIBRARY_PATH during configure!) and fixed it (although I spent
> quite a while editing lib/R/bin/R and wondering an abscence of
> any effect :-)

Please take a look at e.g. config.site, which explains this under LDFLAGS, 
(as does the R-admin manual which INSTALL asks you to read).

> After all the troubles I manage to load an extension, but, frankly, I
> think there were too many problems. It would be very nice if R-project
> reject the idea of using LD_LIBRARY_PATH because its setting is
> considered harmfull and leads to too many problems:
> http://www.linuxmafia.com/faq/Admin/ld-lib-path.html

[Which is Solaris specific, despite the site name.]

Unfortunately, the alternatives lead to even more problems, and this is 
the first report we have had for years of a problem (which can be solved 
on reading the documentation).  As the R-admin manual points out, we 
regularly test on Solaris 8 and give an example there of setting LDFLAGS 
under the Solaris section.

Use of -R is harmful for sure!  It stops R being relocatable (so it either 
could not be tested before being installed or it would not run after 
installation), and it is not at all portable.

Maybe one day when we have libtool tamed we will be able to use the
multiple equivalents of -R or LD_RUN_PATH in a portable-enough way.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list