On Wed, Oct 27, 2010 at 2:43 PM, Simon Urbanek
<simon.urbanek@r-project.org>wrote:

>
> On Oct 27, 2010, at 1:22 PM, Dominick Samperi wrote:
>
> > Hello,
> >
> > In Sections 5.8.1 and 5.8.2 of Writing R Extensions the following pattern
> is
> > suggested
> > for getting the path to a file in another package:
> >
> > PKGB_PATH=Œecho ‚library(packB); cat(system.file("libs",
> package="packB"))‚
> > \
> > | ${R_HOME}/bin/R --vanilla --slaveŒ
> >
> > Is the library(packB) really needed here?
>
> Not that I'm aware of - it's just a check that that package can be used. If
> you omit it you will get an empty string and no error on failure.
>

I did not tell the whole story here. Assume the packB depends on packC in
the sense that packB.dll links to packC.dll.
Then library(packB) will trigger library(packC), and this appears to have
the side effect of eliminating the need to place
the directories containing packB.dll and packC.dll on the search path.

If the library(packB) is not used in this situation there will be a failure
if instead of
cat(sytem.file("libs", package="packB") one uses cat(packB:::getLibs()),
where packB:::getLibs() is defined by system.file("libs",package="packB").

The lesson here (for me) is that packB:::getLibs() has the side-effect of
loading packB.dll,
and this will fail if the OS cannot find packC.dll (so the directory
containing the latter would
have to be placed on the search path if library(packB) is not used above).

Dominick

	[[alternative HTML version deleted]]

