2

I'd like to submit an updated version of an R package ot cran but it's failing because of the note:

Found no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’

I tried the solution here: https://stackoverflow.com/a/42339658/3738150

Running tools::package_native_routine_registration_skeleton(".") yields

#include <stdlib.h> // for NULL
#include <R_ext/Rdynload.h>

/* FIXME:  
   Check these declarations against the C/Fortran source code.
*/

/* .C calls */ 
extern void rW(void *, void *, void *);
extern void ry_bing(void *, void *, void *);
extern void ry_bmf(void *, void *, void *, void *);

static const R_CMethodDef CEntries[] = {
    {"rW",      (DL_FUNC) &rW,      3},
    {"ry_bing", (DL_FUNC) &ry_bing, 3},
    {"ry_bmf",  (DL_FUNC) &ry_bmf,  4},
    {NULL, NULL, 0}
};

void R_init_rstiefel(DllInfo *dll)
{
   R_registerRoutines(dll, CEntries, NULL, NULL, NULL);
   R_useDynamicSymbols(dll, FALSE);
}

which I put in rstiefel_init.c

However, when I check this I get Warning: failed to assign RegisteredNativeSymbol for rW to rW since rW is already defined in the ‘rstiefel’ namespace etc for other definitions.

Any help wou'd be much appreciated!

The packaged I'd like to submit can be found at: https://github.com/pdhoff/rstiefel

  • I think the [documentation](https://cran.r-project.org/doc/manuals/R-exts.html#Registering-native-routines) explains this very well, and that link is also mentioned in the question you referenced. – Alexis Jun 10 '18 at 20:14
  • I've tried following the documentation as well to no avail. A little more direction would be helpful. Is there an example init file I can work from? – user3738150 Jun 10 '18 at 21:26
  • Plenty. I think I used [Rcpp](https://github.com/RcppCore/Rcpp/blob/master/src/Rcpp_init.cpp)'s as initial reference. [Here's](https://github.com/asardaes/dtwclust/blob/master/src/init.cpp) one I use, which is simpler because I only use `.Call` functions. – Alexis Jun 10 '18 at 21:29
  • The problem I keep having is "Warning: failed to assign RegisteredNativeSymbol for rW to rW since rW is already defined in the ‘rstiefel’ namespace". I haven't seen any indication of why this happens or how to fix it. – user3738150 Jun 10 '18 at 21:53
  • I can't check your package right now, but I noticed your C file in the github repo doesn't include `R_ext/Rdynload.h`. I doubt that's the reason but just something I noticed. – Alexis Jun 10 '18 at 22:11

1 Answers1

1

Your R code defines rW <- ..., but by registering a native routine with

{"rW",      (DL_FUNC) &rW,      3},

you're asking R to overwrite that symbol with a symbol representing the C-level function. You could instead register your routine with

{"C_rW",      (DL_FUNC) &rW,      3},

or when you indicate useDynLib(..., .fixes = "C_") in your NAMESPACE as indicated in Writing R Extensions.

Martin Morgan
  • 45,935
  • 7
  • 84
  • 112