From hornik at ci.tuwien.ac.at  Wed May 28 12:18:12 2003
From: hornik at ci.tuwien.ac.at (Kurt Hornik)
Date: Wed May 28 11:26:20 2003
Subject: [Rd] R's DYLD_LIBRARY_PATH override problems on Mac OS X
In-Reply-To: <1BB66614-8FA9-11D7-B7E9-000393CE9026@math.uni-augsburg.de>
References: <17E1872C-8F88-11D7-B37C-000393BB6D36@stat.ucla.edu>
	<1BB66614-8FA9-11D7-B7E9-000393CE9026@math.uni-augsburg.de>
Message-ID: <16084.32468.665397.915680@mithrandir.hornik.net>

>>>>> Simon Urbanek writes:

> On Monday, May 26, 2003, at 04:41  PM, Jan de Leeuw wrote:
>> I don't think  there is a reason to set  DYLD_LIBRARY_PATH in bin/R. 
>> Not even fink sets this variable.
> Well, that's what I think as well .. so my question is, why is it there 
> then?

> My guess is that it's due to the fact that the script was written for 
> all unix platforms, therefore it explicitly sets it since some unixes 
> need it. It is in src/scripts/R.sh.in (this one is from today's 
> R-devel):
> ## NOTE:
> ## We must set this here rather than in the main binary.
> : ${R_LD_LIBRARY_PATH=${R_HOME}/bin:@R_LD_LIBRARY_PATH@}
> if test -z "${@shlibpath_var@}"; then
>    @shlibpath_var@="${R_LD_LIBRARY_PATH}"
> else
>    @shlibpath_var@="${R_LD_LIBRARY_PATH}:${@shlibpath_var@}"
> fi
> export @shlibpath_var@

> ... and in turn autoconf generates:
> darwin* | rhapsody*)
> [...]
> shlibpath_var=DYLD_LIBRARY_PATH

> So what's the most clean way to fix that? One more "if" or for Darwin 
> in R.sh.in? Remove X11 from R_LD_LIBRARY_PATH for Darwin?

The configure code currently has

for arg in ${LDFLAGS} ${FLIBS} ${BLAS_LIBS} ${LAPACK_LIBS} ${X_LIBS} \
           ${TCLTK_LIBS} ${GNOME_LIBS}; do
  case "${arg}" in
    -L*)
      lib=`echo ${arg} | sed "s/^-L//"`
      R_SH_VAR_ADD(R_LD_LIBRARY_PATH, [${lib}], [${PATH_SEPARATOR}])
      ;;
  esac
done

which follows that the idea that any -L flag in the above that was
either given explicitly or determined by configure should be added to
the run time path.  It is one of the autoconf macros which knows about
typical locations of X11 and adds the -L X11 stuff by default.

My preference would be to leave this mechanism untouched but maybe add
to LDFLAGS on platforms where this is necessary.  We already have

## LDFLAGS.
if test -f "/sw/etc/fink.conf"; then
  : ${CPPFLAGS="-I/sw/include -I/usr/local/include"}
  : ${LDFLAGS="-L/sw/lib -L/usr/local/lib"}
else
  : ${CPPFLAGS="-I/usr/local/include"}
  : ${LDFLAGS="-L/usr/local/lib"}
fi

and could add something which adds the frameworks that should come first
in the run time path.

Best
-k


[Rd] R's DYLD_LIBRARY_PATH override problems on Mac OS X
Kurt Hornik