问题
I have created an R package that I would like to submit to CRAN. It contains code that needs to be compiled in plain C and this code depends on the libxml2
library.
My current solution is to let Linux and Mac users install the libxml2-dev
package, which lets them compile and install the R source package.
For Windows, I have created a special binary R-package that contains the required binary dependency. When reading the CRAN guidelines I see that only source packages may be uploaded and that they may not contain any binary files.
After those guidelines, my questions are:
- Is it ok for Mac/Linux to have the user install libxml2-dev prior to installing the R package or are there alternative solutions?
- How should I do for Windows where the libxml2 is not straight forward to install for an end user?
回答1:
As mentioned above, you can just copy over what the xml2 package does:
To get things to work on Linux/MacOS, copy the files
configure
and/src/Makevars.in
. Note that macOS includes a copy of libxml2 by default, so you can safely link to-lxml2
as you would do on Linux.For Windows need to copy the files
src/Makevars.win
andtools/winlibs.R
from xml2. This is a simple script that automatically downloads and statically links libxml2 from rwinlib when building the R package on Windows.
These build scripts are tested to work on (almost) any platform.
来源:https://stackoverflow.com/questions/39568937/how-to-create-cran-ready-r-package-that-has-external-dependency-libxml2