I am very new to R. I would like to create an R package that will call a C ++ function using .Call (). I have a NAMESPACE file, with
useDynLib(mypkg)
where mypkg is also the function name of my C ++ code.
It works if I use this line at the beginning of mypkg.R:
dyn.load("src/mypkg.so")
but I want to use library.dynam instead, so in the zzz.R file I put
.onLoad<-function(libname, pkgname)
{
library.dynam("mypkg", pkgname, libname)
}
It gives an error while checking the package:
...
Error in .Call("mypkg", PACKAGE = "mypkg") :
C symbol name "mypkg" not in DLL for package "mypkg".
Error : unable to load R code in package 'mypkg'
...
It looks like the * .so file is being generated in the wrong place? Why is the / libs folder not created?
I would like the package to be os independent, is there any way to do this with dyn.load?
And this can be a very stupid question, where do pkgname and libname get their data from?
Many thanks for your help.
source
share