Re: [Rd] Sections 5.8.1 and 5.8.2 of Writing R Extensions (LinkingTo)

From: Dominick Samperi <djsamperi_at_gmail.com>
Date: Wed, 27 Oct 2010 15:17:24 -0400

On Wed, Oct 27, 2010 at 2:43 PM, Simon Urbanek <simon.urbanek_at_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]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 27 Oct 2010 - 19:19:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Oct 2010 - 23:50:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive