[R-SIG-Mac] How to find system directory to shared library?
Simon Urbanek
simon.urbanek at r-project.org
Sun May 13 01:25:52 CEST 2007
On May 12, 2007, at 3:43 PM, cstrato wrote:
> Dear all
>
> In my package I need to get the path to the shared library
> "mypackage.so".
> Currently, I use the following code:
>
> mydir <- system.file(package="mypackage")
> mylib <- paste(mydir, "/libs/mypackage.so", sep="")
>
This won't work on any multi-arch R (like any Mac version on CRAN)
and neither on Windows. In most case you shouldn't be accessing it
directly anyway (use library.dynam if you want to load it). If you
really want the path to another package's dylib, you can use
something like
pkg = "mypackage"
mylib = system.file("libs", .Platform$r_arch, paste(pkg, .Platform
$dynlib.ext, sep=''), package=pkg)
Cheers,
Simon
> This did work with FC4 running R-2.4.1 and on my Intel-Mac running the
> development version of R-2.5.0, which I did compile from source.
>
> However, now I have downloaded and installed R-2.5.0.dmg and get an
> error since the shared library is now located in: "/libs/i386/
> mypackage.so"
> So I changed the code to:
>
> mydir <- paste(system.file(package="mypackage"), "libs", sep="/");
> if (list.files(mydir) == "mypackage.so") {
> mylib <- paste(mydir, "mypackage.so", sep="/");
> } else {
> mylib <- paste(mydir, list.files(mydir), "mypackage.so",
> sep="/");
> }
>
> This works since there is only one subdirectory "i386", but not if
> there
> are "i386" and "ppc" subdirectories.
>
> Sorrowly, the following does not work:
> system.file("mypackage.so", package = "mypackage")
>
> My question is, is there a better way to find the path to the shared
> library?
>
> Best regards
> Christian
> _._._._._._._._._._._._._._._._
> C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
> V.i.e.n.n.a A.u.s.t.r.i.a
> _._._._._._._._._._._._._._._._
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>
More information about the R-SIG-Mac
mailing list