Rcpp - Linking to DLL from another package?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Rcpp - Linking to DLL from another package?

Stravs, Michael
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]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp - Linking to DLL from another package?

Dirk Eddelbuettel

(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 | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp - Linking to DLL from another package?

Jeroen Ooms-2
On Mon, Dec 18, 2017 at 2:40 PM, Dirk Eddelbuettel <[hidden email]> 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.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Rcpp - Linking to DLL from another package?

Dirk Eddelbuettel

On 18 December 2017 at 16:10, Jeroen Ooms wrote:
| On Mon, Dec 18, 2017 at 2:40 PM, Dirk Eddelbuettel <[hidden email]> 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.

That is nice too, but doesn't in your case the object code comes from the
external libxml2 only?

Michael wanted to get at code from another R package, and those shared
libraries from R packages are not system-wide visible. Hence the problem.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel