简体   繁体   English

是否可以在不安装Rtools的情况下在R中使用Rcpp代码?

[英]Can I use the Rcpp code in R without installing Rtools?

The Window HPC server in my lab does not have Rtools, so I've got this message when I sourced the Rcpp code. 我的实验室中的Window HPC服务器没有Rtools,因此在获取Rcpp代码时收到了此消息。

Warning message:
running command 'make -f "C:/PROGRA~1/R/R-32~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="sourceCpp_1.dll" WIN=64 TCLBIN=64 OBJECTS="MultiBayes.v1.o"' had status 127 
Error in sourceCpp("./rcode/MultiBayes.v1.cpp") : 
  Error 1 occurred building shared library.

WARNING: The tools required to build C++ code for R were not found.

Please download and install the appropriate version of Rtools:

http://cran.r-project.org/bin/windows/Rtools/

Execution halted

Since the administrative staff says it might take long time to install Rtools in the server, I'm wondering if there is another way to escape this problem and run the Rcpp code without installing Rtools. 由于管理人员说在服务器上安装Rtools可能花费很长时间,所以我想知道是否还有另一种方法可以解决此问题并在不安装Rtools的情况下运行Rcpp代码。

As far as I know, building a package would not be helpful since it also uses Rtools when installing it. 据我所知,构建软件包没有帮助,因为它在安装时也会使用Rtools。 Please correct me if wrong. 如果有错,请纠正我。

Can I detour this to run the code? 我可以绕道运行代码吗?

Thanks for any comments and ideas. 感谢您的任何意见和想法。

Briefly: 简要地:

  1. The narrow answer is that "yes, in theory you get by without Rtools" if you happened to install binary-identical version (including patches) of gcc et al. 如果您碰巧安装了gcc等人的二进制相同版本(包括补丁程序),那么狭narrow的答案是“是的,理论上您不需要Rtools就可以了”。 In practice, you cannot (on Windows). 实际上,您不能(在Windows上)。

  2. An easy way around is to compile a package of your code outside of the HPC server and deploy the binary build of that package on it. 一个简单的方法解决办法是编译代码的HPC服务器之外,并在其上部署该包的二进制版本。 Easy. 简单。 And no Rtools needed for binaries! 而且二进制文件不需要Rtools!

  3. If you do HPC you may also want to look into Linux. 如果您执行HPC,则可能还需要研究Linux。

Thanks to Dirk Eddelbuettel, I go on the solution 2 to handle my problem 感谢Dirk Eddelbuettel,我继续进行解决方案2来解决我的问题

Here's what I did. 这就是我所做的。

  1. Build the R package including .cpp code, and create the package source (eg YourPkgName_1.0.tar.gz) 构建包括.cpp代码的R包,并创建包源(例如YourPkgName_1.0.tar.gz)

  2. Install the package to create the library in your desktop. 安装软件包以在您的桌面上创建库。 For example, 例如,

    install.packages(pkgs = "C:/Users/User/Desktop/YourPkgName_1.0.tar.gz", repos = NULL, type="source") install.packages(pkgs =“ C:/Users/User/Desktop/YourPkgName_1.0.tar.gz”,存储库= NULL,键入=“ source”)

  3. Move your installed library from the default folder (your desktop) to the server. 将已安装的库从默认文件夹(您的桌面)移动到服务器。 My local url was 我的本地网址是

    C:\\Program Files\\R\\R-3.5.1\\library C:\\ Program Files \\ R \\ R-3.5.1 \\ library

  4. You can load the cpp function in R under your server where Rtools is not installed by including the following command in your R script. 通过在R脚本中包含以下命令,可以在未安装Rtools的服务器下的R中加载cpp函数。

    library("YourPkgName", lib.loc = "YourPersonalLibraryDirectory") library(“ YourPkgName”,lib.loc =“ YourPersonalLibraryDirectory”)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM