Rcpp找不到Rtools:“构建共享库时发生错误1" [英] Rcpp can't find Rtools: "Error 1 occurred building shared library"
问题描述
我在使用 Rcpp 时遇到了一个简单的设置问题,但无法使其正常工作.我试着按照这个例子 http://www.r-bloggers.com/user2013-the-rcpp-教程/但是当执行这段代码时:
I am running into a simple setup problem with Rcpp and I cannot get it to work. I tried to follow this example http://www.r-bloggers.com/user2013-the-rcpp-tutorial/ But when executing this code:
library(Rcpp)
evalCpp("1 + 1", showOutput= TRUE)
我得到这个输出
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:
- 使用 install.Rtools() 安装了 Rtools 31
- 在 C:\R\R-3.0.1 中安装了 R
- 库文件存放在 C:\R\R-3.0.1\library
- 在 C:\R\RStudio 中安装了 Rstudio
- 将我的脚本放在 C:\R
大多数类似的问题似乎表明文件路径中有一个空格,因此我几乎移动了所有我能移动的东西.但它仍然无法找到 Rtools.我在笔记本电脑和台式机上都试过了,但都不起作用,所以可能是我在结构上做错了.
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. 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.
推荐答案
看起来您的 R 二进制文件和 Rtools 目录都不在您系统的 PATH
环境变量中.试试这个:
Looks like neither your R binaries nor Rtools directories are in your system's PATH
environment variable. 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 ...]
如果您的目录 C:\R\R-3.0.1\bin\x64\
和 C:\R\Rtools\bin\
&C:\R\Rtools\gcc-*.*.*\bin\
(用你的 gcc-binaries 版本替换 \gcc-*-*-*\)没有列出,需要的找不到组件.为了安全起见,还要创建一个名为 CYGWIN
的系统变量,其值为 nodosfilewarning
.
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.
To be on the safe side, also create a system variable called CYGWIN
with the value nodosfilewarning
.
更改/创建PATH
和CYGWIN
变量后,重新启动.然后它应该可以工作,您可以将源代码任何地方放在您的机器上,也可以使用 R CMD SHLIB
手动编译它们.
After changing/creating the PATH
and CYGWIN
variables, reboot. Then it should work and you can place your sources anywhere on your machine and also compile them manually using R CMD SHLIB
.
这篇关于Rcpp找不到Rtools:“构建共享库时发生错误1"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!