Does installing an R package with Rcpp require Rtools (Windows)

672 views Asked by At

I am making an R package with Rcpp. It works fine on my machine which has Rtools installed. But recently, I tried to install my package locally on a different machine (Windows) and got a compiling error. The reason was that on that machine there was no g++ compiler (for Windows, g++ is provided with Rtools). After installing Rtools, it worked just fine.

So the question is, if I upload it to CRAN, does it still requires users to install Rtools by hand? Or does the function install.package() detect and install Rtools for them?

Also, if you guys know some packages written with Rcpp, please let me know. I'd like to take a look how it works.

2

There are 2 answers

3
Ben Bolker On BEST ANSWER

So the question is, if I upload it to CRAN, does it still requires users to install Rtools by hand?

No.

Or does the function install.package() detect and install Rtools for them?

No.

What happens is that CRAN builds pre-compiled binary files that can be installed by Windows and MacOS users without the need for compilers and related tools.

Also, if you guys know some packages written with Rcpp, please let me know. I'd like to take a look how it works.

rr <- devtools::revdep("Rcpp")
length(rr) ## 907

or see the Rcpp page on CRAN.

0
coatless On

Users, e.g. people who download it via install.package(), are actually downloading a "compiled" version of the packaged called a binary that is maintained by CRAN. They will only ever need a copy of R.

On the other hand, Developers, e.g. people who are creating it, require development tools that are system specific. For those on the Windows platform, they must have a local install of Rtools on their machine. For developers on macOS, they must have their own copies of gfortran binaries and xcode developer line tools.

Lastly, there are many such Rcpp packages available to look to for inspiration...