From maechler at stat.math.ethz.ch  Fri Feb 10 17:26:07 2017
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri, 10 Feb 2017 17:26:07 +0100
Subject: [Rd] R CMD check error (interfacing to C API of other pkg)
In-Reply-To: <f40b15$5q8gau@ironport10.mayo.edu>
References: <f40b15$5q1tpg@ironport10.mayo.edu>
	<1486630455.1872.36.camel@iarc.fr>
	<f40b15$5q60ma@ironport10.mayo.edu>
	<1486661008.1872.91.camel@iarc.fr>
	<f40b15$5q8gau@ironport10.mayo.edu>
Message-ID: <22685.59807.856379.992073@stat.math.ethz.ch>

>>>>> Therneau, Terry M , Ph D <therneau at mayo.edu>
>>>>>     on Thu, 9 Feb 2017 12:56:17 -0600 writes:

    > Martyn,
    > No, that didn't work.
    > One other thing in the mix (which I don't think is the issue) is that I call one of the 
    > C-entry points of expm.  So the DESCRIPTION file imports expm, the NAMESPACE file imports 
    > expm, and the init.c file is

    > #include "R.h"
    > #include "R_ext/Rdynload.h"

    > /* Interface to expm package. */
    > typedef enum {Ward_2, Ward_1, Ward_buggy_octave} precond_type;
    > void (*expm)(double *x, int n, double *z, precond_type precond_kind);
    > void R_init_hmm(DllInfo *dll)
    > {
    >      expm = (void (*)) R_GetCCallable("expm", "expm");
    > }

    > I don't expect that this is the problem since I stole the
    > above almost verbatim from the msm package.

    > Terry T.

Hmm.  Yes, I can see that the CRAN package  msm  does do this, indeed.

It is interesting if/why that does not produce any notes or rather even warnings.
In principle, if you use the C API of 'expm'  you should use
  'LinkingTo: expm'

see *the* manual, specifically the section

    https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Linking-to-native-routines-in-other-packages

and that section does mention that (unfortunately in my view)
you also should use 'Imports:' or 'Depends:' in addition to the 'LinkingTo:'

Note howver that  'expm' would not have to mentioned 
in the NAMESPACE file.... unless your R functions do use some of
expm's R level functionality.


Martin



[Rd] R CMD check error (interfacing to C API of other pkg)
Martin Maechler