Hi, I am trying to make a package B that extends another package A. Package A uses Rcpp, and I want to extend a class X used there. So package A has src/X.h and inst/include/X.h class X { ... } src/X.cpp X::X( arguments ) { ... } My package B wants to do this: DESCRIPTION [...] LinkingTo: Rcpp, RcppArmadillo, A Imports: Rcpp, RcppArmadillo, A src/Y.h class Y: public X { ... } src/Y.cpp Y::Y( arguments ): X(arguments) { ... } Can I somehow make the package link to the library A.dll or its corresponding Linux equivalent? (Note: the files in inst/include will already be a pull request from me to the package A author, so a limited pull request for more changes is feasible, but I would like to keep it minimal. Dr. Michael Stravs Eawag Umweltchemie BU E 23 ?berlandstrasse 133 8600 D?bendorf +41 58 765 6742 [[alternative HTML version deleted]]
(Moderately wrong list: r-package-devel for packaging questions, rcpp-devel for Rcpp questions) On 18 December 2017 at 13:24, Stravs, Michael wrote: | I am trying to make a package B that extends another package A. Package A uses Rcpp, and I want to extend a class X used there. It doesn't really matter (for the issue at hand) if you use Rcpp or not -- R only offers us C interfaces so C interfaces are all we got. And they don't know classes. I worked through that in some of my packages. See eg RcppXts which "extends" in your sense xts by allowing C++ level access from another package. The one key aspect is that _everything you want to call from B must be explicitly exported by A_. See Writing R Extensions for details. If you could rewrite your class A to be header-only then you could just include it via LinkingTo. But that is a different story. In short, "No Free Lunch" and no automagic mechanisms. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
On Mon, Dec 18, 2017 at 2:40 PM, Dirk Eddelbuettel <edd at debian.org> wrote:> > (Moderately wrong list: r-package-devel for packaging questions, rcpp-devel > for Rcpp questions) > > On 18 December 2017 at 13:24, Stravs, Michael wrote: > | I am trying to make a package B that extends another package A. Package A uses Rcpp, and I want to extend a class X used there.Another, perhaps simpler example is the xslt package which is an extension for the xml2 package. The xml2 package exposes its object types (via ./inst/include/xml2_types.h) so that the xslt package get to the underlying libxml2 objects.
Possibly Parallel Threads
- Rcpp - Linking to DLL from another package?
- Function name exported incorrectly in DLL, strange entries in tmp.def
- Rcpp - Linking to DLL from another package?
- Package Rcpp: Question conerning source code of cpp files and related question
- calling native routines in another package (Sec 5.4.2 of Writing R Extensions)