[Rd] Sligthly OT Re: Makefile for embedding OpenBUGS in R package
hin-tak.leung at cimr.cam.ac.uk
Wed Aug 8 22:58:13 CEST 2007
Tobias Verbeke wrote:
> Actually, I think Hin-Tak is right about the absolute path. Even when
> the R code will call the executable that resides in that directory, R
> will call it from any directory and that (current) directory will be
> resolved (at least that is what I observe experimentally).
> When such an absolute path is coded in, everything runs fine -- we now
> can run a BUGS script from within R under GNU/Linux !
> It would however be nice to solve the remaining problem of the
> absolute path in the dlopen() call, i.e. being able to fill in
> `dynamically' the library path to which the package is actually installed.
> Is there a way to have the library path to which a package is installed
> available during package installation and then to do some
> text-processing to fill in this path dynamically into the C file i.e.
> as argument of dlopen() before compiling it?
I don't know if there is a neater way of doing this, but one somewhat
clunky way is to process the result of .libPath() , append each of its
elements by <package>/inst/OpenBUGS/bugs.so and test if the file exists,
(.libPath() should be quite a small character vector so it should be too
slow to test every one), then pass the result as an explicit
argument to the main bugs binary before everything else it takes.
I think there is a more clever way of telling where the current package
is installed/located but it escapes me at the moment. Perhaps the source
code of data() (just typying 'data' without the () at the comment prompt
will display the source), can shed some lights on this, since data()
does something quite similiar.
Good luck, and it is an interesting discussion so far.
More information about the R-devel