<br><br><div class="gmail_quote">On Wed, Oct 27, 2010 at 2:43 PM, Simon Urbanek <span dir="ltr"><<a href="mailto:simon.urbanek@r-project.org">simon.urbanek@r-project.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
On Oct 27, 2010, at 1:22 PM, Dominick Samperi wrote:<br>
<br>
> Hello,<br>
><br>
> In Sections 5.8.1 and 5.8.2 of Writing R Extensions the following pattern is<br>
> suggested<br>
> for getting the path to a file in another package:<br>
><br>
</div>> PKGB_PATH=Śecho ‚library(packB); cat(system.file("libs", package="packB"))‚<br>
> \<br>
> | ${R_HOME}/bin/R --vanilla --slaveŚ<br>
<div class="im">><br>
> Is the library(packB) really needed here?<br>
<br>
</div>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.<br></blockquote><div><br>I did not tell the whole story here. Assume the packB depends on packC in the sense that packB.dll links to packC.dll.<br>
Then library(packB) will trigger library(packC), and this appears to have the side effect of eliminating the need to place<br>the directories containing packB.dll and packC.dll on the search path.<br><br>If the library(packB) is not used in this situation there will be a failure if instead of<br>
cat(sytem.file("libs", package="packB") one uses cat(packB:::getLibs()), <br>where packB:::getLibs() is defined by system.file("libs",package="packB").<br><br>The lesson here (for me) is that packB:::getLibs() has the side-effect of loading packB.dll,<br>
and this will fail if the OS cannot find packC.dll (so the directory containing the latter would<br>have to be placed on the search path if library(packB) is not used above).<br><br>Dominick<br><br></div></div><br>