hi, i'm having some trouble getting a package to load a shared library
object in .onLoad(...)

i have a shared object file, say "mylib.so".

if i start an R session, and via the CLI specify the actual library
via:
> dyn.load("mylib.so")
everything works quite well (i.e. i can then follow with some .Call
(...) methods)

now, i'd like to include this shared library in my package.
assume that the .c file has already been compiled and i have the .so
file at some PATH.
in my zzz.R file i include:

.onLoad <- function(libname, pkgname) {
  library.dynam("mylib", lib.loc = PATH)
}

when i load the package, however, i get:

Error in .find.package(package, lib.loc, verbose = verbose) :
  there are no packages called 'RCurl', 'bitops', 'rjson', 'stats',
'graphics', 'grDevices', 'utils', 'datasets', 'methods', 'base'

so it appears i need to specify the package name, so if i change the
call to:

  library.dynam("mylib", pkgname, lib.loc = PATH), i get:

Error in .find.package(package, lib.loc, verbose = verbose) :
  there is no package called 'mypackage'
Error : .onLoad failed in 'loadNamespace' for 'mypackage'

which makes sense because the package namespace isn't attached yet.
so i'm not really sure what to specify for the package parameter of
library.dynam.

i've elected to try to use library.dynam() instead of useDynLib() in
the NAMESPACE file because this is a VERY customized package and the
library i'm using will change often enough and will probably be placed
in a non-standard location on the user's system.

ideas?

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to