Building R package with code C, dll missing

I am trying to create an R package that calls some C routines via .Call.

All functions work fine if I manually do R CMD SHLIB and then dyn.load.dll.

Now I am creating a package with the R CMD assembly.

I have put all the C code in the src folder along with the .h files for some of the libraries I am adding. When I run R CMD build NAMEPACKAGE everything seems fine, but then when I run R CMD check NAMEPACKAGE I get the following errors:

*** arch - i386
Error in library.dynam(lib, package, package.lib) : 
  DLL 'NAMEFUNC' not found: maybe not installed for this architecture?
Error: loading failed
Execution halted
*** arch - x64
Error in library.dynam(lib, package, package.lib) : 
  DLL 'NAMEFUNC' not found: maybe not installed for this architecture?
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'

      

I was trying to get some information online, I have a feeling that I have to write a Makevars file, but to be honest, I spent a lot of time on the Writing R extension (1.2.1) tutorial and I am really trying to figure out what exactly is me have to do. Can someone please explain to me how to solve the problem? Think I would like to send my package to CRAN. Thank.

+3


source to share


1 answer


I just found out what the problem is! It was (as usual) pretty stupid, I didn't know that even if you call a specific function with a specific name, the dll associated with it is automatically called with the package name and not the function itself, for example it happens when you just create your DLL via R CMD SHLIB. So in NAMESPACE I had to add useDynLib (NAMEOFPACKAGE) instead of useDynLib (NAMEOFFUNCTION).



+1


source







All Articles