From edd at debian.org  Fri Jan 13 21:58:15 2017
From: edd at debian.org (Dirk Eddelbuettel)
Date: Fri, 13 Jan 2017 14:58:15 -0600
Subject: [Rd] calling native routines in another package (Sec 5.4.2
	of	Writing R Extensions)
In-Reply-To: <CAKctRd32RUVntt4GD4G4DyzXwXPu4Vg4cmexO4T0ZpuW8v77CQ@mail.gmail.com>
References: <CAKctRd32RUVntt4GD4G4DyzXwXPu4Vg4cmexO4T0ZpuW8v77CQ@mail.gmail.com>
Message-ID: <22649.16231.36234.410307@max.nulle.part>


On 13 January 2017 at 13:25, Charles Geyer wrote:
| I just (apparently) figured out how to do the stuff described in
| Section 5.4.2 of
| Writing R Extensions.  I put my test toy packages on github
| <https://github.com/cjgeyer/linkingTo> for anyone to copy.  If anyone
| cares to read the README and the bits of code it links to and tell me
| anywhere I am wrong, I would be grateful.
| 
| But the main point of this e-mail is a complaint about that section of
| Writing R Extensions.  It says (even in R-devel) "A CRAN example of
| the use of this mechanism is package lme4, which links to Matrix." but
| that does not appear to be true anymore.  I cannot see any inclusion
| of headers from Matrix in lme4 nor any call to R_GetCCallable.  I did
| find the file inst/include/Matrix_stubs.c in the Matrix package
| somewhat helpful (although mystifying at first).
| 
| So this can be considered a documentation bug report (if I am
| correct).  Do I need to do an official bugzilla one?
| 
| Just a further check.  lme4 (1.1-12) does not have Matrix in the
| LinkingTo field of its DESCRIPTION file, so headers from Matrix cannot
| be used.  And
| 
|     grep R_Get *.[ch]*
| 
| in the src directory of lme4 returns nothing.

There are a few other packages doing this

RcppXts uses exported C code from xts [1]
RcppRedis users export C code from RApiSerialize
RcppKalman uses expm
Vincent Goulet just release expint which offers an API

Dirk

[1] Vincent and I went over this recently when he prepared expint. While I
(re-)wrote a large part of the xts header for use by RcppXts and others, I
didn't leave my name in the header so Jeff got author credits for expint
instead.  C'est la vie.

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



[Rd] calling native routines in another package (Sec 5.4.2 of Writing R Extensions)
Dirk Eddelbuettel