简体   繁体   English

Rcpp找不到Rtools:“构建共享库时出现错误1”

[英]Rcpp can't find Rtools: “Error 1 occurred building shared library”

I am running into a simple setup problem with Rcpp and I cannot get it to work. 我遇到了一个简单的设置问题与Rcpp,我无法让它工作。 I tried to follow this example http://www.r-bloggers.com/user2013-the-rcpp-tutorial/ But when executing this code: 我试着按照这个例子http://www.r-bloggers.com/user2013-the-rcpp-tutorial/但是在执行这段代码时:

library(Rcpp)
evalCpp("1 + 1", showOutput= TRUE)

I get this output 我得到了这个输出

C:/R/R-30~1.1/bin/x64/R CMD SHLIB -o "sourceCpp_33280.dll" "file8d01b0a675b.cpp" 
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput,  : 
  Error 1 occurred building shared library.
WARNING: Rtools is required to build R packages but is not currently installed. 
Please download and install the appropriate version of Rtools before proceeding:

I have done the following things in an attempt to make it work: 为了使它工作,我做了以下事情:

  • installed Rtools 31 with install.Rtools() 用install.Rtools()安装Rtools 31
  • installed R in C:\\R\\R-3.0.1 在C:\\ R \\ R-3.0.1中安装了R.
  • library files are stored in C:\\R\\R-3.0.1\\library 库文件存储在C:\\ R \\ R-3.0.1 \\ library中
  • installed Rstudio in C:\\R\\RStudio 在C:\\ R \\ RStudio中安装了Rstudio
  • placed my script in C:\\R 把我的脚本放在C:\\ R中

most similar issues seem to suggest that a space was in the file path, therefore i moved pretty much everything I could. 大多数类似的问题似乎表明文件路径中有一个空格,因此我几乎可以移动所有内容。 But still it fails to locate Rtools. 但仍无法找到Rtools。 I tried it on my laptop and on my desktop and both don't work, so there is probably something structural I am doing wrong. 我在我的笔记本电脑和桌面上试了一下它们都没有用,所以可能有一些结构我做错了。

Looks like neither your R binaries nor Rtools directories are in your system's PATH environment variable. 看起来您的R二进制文件和Rtools目录都不在您系统的PATH环境变量中。 Try this: 尝试这个:

> writeLines(strsplit(Sys.getenv("PATH"), ";")[[1L]])
C:\R\Rtools\bin
C:\R\Rtools\gcc-4.6.3\bin
C:\R\R-devel\bin\x64
[... and so on ...]

If your directories C:\\R\\R-3.0.1\\bin\\x64\\ and C:\\R\\Rtools\\bin\\ & C:\\R\\Rtools\\gcc-*.*.*\\bin\\ (replace \\gcc-*-*-*\\ with your version of the gcc-binaries) are not listed, the needed components can't be found. 如果你的目录是C:\\R\\R-3.0.1\\bin\\x64\\C:\\R\\Rtools\\bin\\C:\\R\\Rtools\\gcc-*.*.*\\bin\\ (替换\\ gcc - * - * - * \\与您的gcc-binaries版本)未列出,无法找到所需的组件。 To be on the safe side, also create a system variable called CYGWIN with the value nodosfilewarning . 为了安全起见,还要创建一个名为CYGWIN的系统变量,其值为nodosfilewarning

After changing/creating the PATH and CYGWIN variables, reboot. 更改/创建PATHCYGWIN变量后,重新启动。 Then it should work and you can place your sources anywhere on your machine and also compile them manually using R CMD SHLIB . 然后它应该工作,您可以将您的源放置在您的机器上的任何位置 ,并使用R CMD SHLIB手动编译它们。

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

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