[Rcpp-devel] Creating an R package using an existing .so file

Peter Crowther peter.crowther at melandra.com
Fri Nov 6 10:30:39 CET 2020


On Fri, 6 Nov 2020 at 02:11, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 4 November 2020 at 15:24, Jon Davidson wrote:
> | I have an existing Rcpp module that has already been compiled into a .so.
> | How can I integrate this into an R package?
>
> I am afraid you can't as an .so file can only be used on one architecture,
> and likely one subsets thereof (i.e. a Debian object file may not work on
> Fedora, or Ubuntu, or maybe even a different Debian version).
>
> That is why "the documentation" (ie WRE, CRAN Policy) say source only.
>

If you *really* wanted to go down this path, you could write a shim and
distribute that as source.  That shim could then somehow deduce the
appropriate compiled version and load it; the shim could, if you wished,
even download it.

This approach has the following notable points:

* If the Rcpp module depends on any part of Rcpp (it will!) and has been
compiled, whether into a .so or something else, then **it is already bound
by the terms of GPLv2 or later** (see the Rcpp FAQ 1.5).  If you distribute
the compiled work, then the infectious nature of GPL means you must also
make the source available.  Rcpp does not provide a way of distributing
compiled modules as a way of protecting IP, which I suspect is what you're
trying to do here.

* Your module would not be accepted by CRAN, so you would need your own
distribution mechanism.

* As Dirk points out, compiled code is not portable between OSs and
architectures, and often not between versions or distributions of one OS.
If you go down this route, expect to have to provide many different .so
files, including for some very unusual systems - which in turn means you'll
end up buying/renting tin for odd systems *or* not supplying your module
for them.  Fancy compiling for the Raspberry Pi?  At least that's only
$35.  How about IBM's Power9 architecture?

My suggestion, I'm afraid, would be "Yeah.  Don't do that."

Cheers,

- Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20201106/fe6f0154/attachment.html>


More information about the Rcpp-devel mailing list