[Bioc-devel] Warning "Register native routines" during BiocCheck

Kevin Ushey kevinushey at gmail.com
Sun Sep 21 17:43:14 CEST 2014


Another thing worth noting -- the .C interface is highly discouraged now;
you should prefer .Call (or for variable numbers of arguments, .External)
instead.

FWIW, this process of function registration can be entirely automated -- I
have a proof of concept for this in my Kmisc package, at:

https://github.com/kevinushey/Kmisc/blob/master/R/registerFunctions.R


The idea is, for any C/C++ functions you would like to be registered, you
just put `// [[register]]` on top of the function definition, and then call
`Kmisc::registerFunctions()` in the base directory of your package to
automatically generate all of the native routine registration boilerplate.
The functions are registered with some prefix; by default 'C_'. One could
imagine calling this in `configure` to create the boilerplate on package
build automatically, for example.

That said, it currently only works with the .Call interface, but it would
be simple enough to extend for the other interfaces as well.

Personally, I would advocate for a (more robust) version of this being
integrated into the BioC ecosystem somewhere, just to alleviate the pain of
generating the boilerplate by hand (especially because it's so easy to miss
something, or get something wrong, as we just saw.) I am sure a lot of
users have bumped into the BiocCheck warnings for native routine
registration, and gotten frustrated with how to proceed...

Anyway, if you want to try it out:

devtools::install_github("kevinushey/Kmisc") ## needs devtools, of course
## annotate functions you want to register with // [[register]]
Kmisc::registerFunctions()


Cheers,
Kevin

On Sun, Sep 21, 2014 at 8:31 AM, Gabe Becker <becker.gabe at gene.com> wrote:

> Does the DLL that gets created have a symbol called coxmat? On unixalikes
> nm [file] will show the symbols in the library.
>
> If coxmat (by itself) is not a symbol you may be running afoul of CPP name
> mangling.  Try using extern 'C' { } around the function declaration if that
> is the case.
>
> ~G
>
> On Sep 21, 2014 7:12 AM, 张雨晴 <zhangyuqing.pkusms at gmail.com> wrote:
> >
> > Hello,
> >
> > I am trying to develop a new package named simulatorZ and submit it to
> the
> > Bioconductor project. It contains a cpp file(coxformatrices.cpp) under
> > /src. But
> > there is a problem in registering native routines, which results in a
> > warning during BiocCheck. The cpp file already contains the registration
> > information below:
> >
> > R_CMethodDef cMethods[] = {
> >         {"coxmat", (DL_FUNC) &coxmat, 26},
> >         NULL
> > };
> > void R_init_coxformatrices(DllInfo *info)
> > {
> >         R_registerRoutines(info, cMethods, NULL, NULL, NULL);
> > }
> >
> > coxmat is the name of the function. Also, the NAMESPACE uses useDynLib:
> >
> > useDynLib(simulatorZ, .registration=TRUE)
> >
> > But the warning still exists. The structure of the whole package is
> > available at https://github.com/zhangyuqing/simulatorZ.
> >
> > Does anyone know how to fix it? I'd really appreciate your help!
> >
> > Yuqing
> >
> > --
> > 张雨晴
> > ZHANG Yuqing
> > School of Mathematical Sciences, Peking University
> > Beijing P.R.China 100871
> > Tel:010-62750534
> > Cell:13439586850
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > Bioc-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/bioc-devel
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>

	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list