How to create CRAN ready R package that has external dependency libxml2

橙三吉。 提交于 2020-01-13 05:13:48

问题


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:

  1. Is it ok for Mac/Linux to have the user install libxml2-dev prior to installing the R package or are there alternative solutions?
  2. 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 and tools/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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!