安装错误和 运行 rcpp

Error installing and running rcpp

我是 R 的新手,很抱歉提出了一个愚蠢的问题。我正在尝试获取 rcpp 运行ning,但我陷入了 R 的无限循环,要求我重新安装 RTools。

我大致遵循了 this blog post 中的代码,尽管第一次关闭时我手动安装了所有内容,随后我又重新安装了几次。我是 运行ning Windows 7,R 版本 3.1.2,R Studio 版本 0.98.1091(不是说这应该很重要)和 RTools 3.1.

我的控制台经过编辑的亮点如下:

> library(installr) 
Welcome to installr version 0.15.3...

> install.Rtools()
Loading required package: devtools
No need to install Rtools - You've got the relevant version of Rtools installed

> find_rtools()
[1] TRUE

> library(Rcpp)
> evalCpp("1+1")

Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput,  :
Error 65535 occurred building shared library.

此时弹出一个对话框说:

Install Build Tools Compiling C/C++ code for R requires installation of additional build tools. Do you want to install the additional tools now?

然后我被指示再次从 cran 下载并重新安装 RTools 3.1。

我发现这可能是 PATH 变量的问题,但我尝试了各种方法,包括:

  1. PATH 变量中没有(额外的)内容
  2. 包括对 R (C:\Program Files\R\R-3.1.2\bin\x64) 和 RTools (C:\RBuildTools.1\bin;C:\RBuildTools.1\gcc-4.6.3\bin;) 在路径中。一次先用 RTools,一次先用 R
  3. 按照初始安装文件的指示,在 PATH 中仅包含对 RTools 的引用。

任何关于尝试的想法都将不胜感激!

编辑

根据 Dirk 的评论,我似乎对 RTools 的安装方式有疑问。我已经按照几个博客/教程中关于如何安装 RTools 的说明进行操作;一切都无济于事(还!)

This GitHub page 给出了一些关于如何安装和检查安装是否有效的说明。我已经完成了所有检查(请参阅下面的控制台副本),看起来我已经安装了 RTools,但是当我再次尝试 运行 evalCPP() 时,我得到了相同的错误在指示我安装 RTools 之前。

> Sys.getenv('PATH')
[1] "C:\Program Files\R\R-3.1.2\bin\x64;C:\RTools\bin;C:\RTools\gcc-4.6.3\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Enterprise Vault\EVClient\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\"
Warning message:
printing of extremely long output is truncated

> system('g++ -v')
Using built-in specs.
COLLECT_GCC=C:\RTools\GCC-46~1.3\bin\G__~1.EXE
COLLECT_LTO_WRAPPER=c:/rtools/gcc-46~1.3/bin/../libexec/gcc/i686-w64-mingw32/4.6.3/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /data/gannet/ripley/Sources/mingw-test3/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --prefix=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --with-gmp=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpfr=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpc=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --disable-shared --enable-static --enable-targets=all --enable-languages=c,c++,fortran --enable-libgomp --enable-sjlj-exceptions --enable-fully-dynamic-string --disable-nls --disable-werror --enable-checking=release --disable-win32-registry --disable-rpath --disable-werror CFLAGS='-O2 -mtune=core2 -fomit-frame-pointer' LDFLAGS=
Thread model: win32
gcc version 4.6.3 20111208 (prerelease) (GCC) 

> system('where make')
C:\Rtools\bin\make.exe

我还查看了 Appendix D of R Installation and Admin. I can't see anything in here I've not already tried except for section D.4,这意味着我可能需要使用已安装的 RTools 从源代码重建 rcpp。我没有时间马上做这件事,但会尝试一下,除非有人说这条路线不值得我花时间。

编辑 v2

所以我尝试从源代码构建 rcpp ...但也没有用。我从 the CRAN Rcpp package page 下载了包源和 windows 二进制文件。在 R 控制台中,我现在得到:

> install.packages(pkgs = "C:/Rcpp_0.11.4.tar.gz", repos = NULL, contriburl = NULL, type = "source", verbose = TRUE)
Installing package into ‘C:/Users/james.macadie/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
system (cmd0): C:/PROGRA~1/R/R-31~1.2/bin/x64/R CMD INSTALL
Warning in install.packages :
  package ‘C:/Rcpp_0.11.4.tar.gz’ is not available (for R version 3.1.2)

我想我的活跃问题现在可以归结为:

编辑 v3

运行 evalCppshowOutput= TRUEverbose = TRUE 我想我已经将错误追溯到 R CMD SHLIB 不工作。我遵循了 this blog,它展示了如何直接使用命令行 R。然而,当我到达 R CMD SHLIB sequence_examples.c 行时,执行直接跳到下一个命令行,不做任何事情,在目录中生成任何文件或抛出任何错误。我在命令行尝试了 运行ning --help 选项,但得到了同样的错误:

C:\Users\james.macadie> R --help


Or: R CMD command args

where 'command' is one of:
  INSTALL  Install add-on packages
  REMOVE   Remove add-on packages
  SHLIB    Make a DLL for use with dynload
  BATCH    Run R in batch mode
  build    Build add-on packages
  check    Check add-on packages
  Rprof    Post process R profiling files
  Rdconv   Convert Rd format to various other formats
  Rdiff    difference R output files
  Rd2pdf   Convert Rd format to PDF
  Rd2txt   Convert Rd format to pretty text
  Stangle   Extract S/R code from vignette
  Sweave    Process vignette documentation
  config   Obtain configuration information about R
  open     Open a file via Windows file associations
  texify   Process a latex file

Use
  R CMD command --help
for usage information for each command.


C:\Users\james.macadie> R CMD SHLIB --help

C:\Users\james.macadie>

N.B。对于那些阅读早期代码示例的人来说 post 自从那些代码快照以来我已经更改了一些东西:

一如既往地感谢您的任何建议

最后有点偏左。受到 following post 的启发,我查看了 ComSpec 环境变量。不太确定如何,但我将其设置为 "cmd.exe".

删除双引号,所以它说 cmd.exe,然后重新启动修复一切。

感谢所有试图提供帮助的人。

尝试安装 Twitter 的 BreakoutDetection(也是用 cpp 编写的)时遇到同样的死循环问题

通过执行以下

修复
Sys.setenv(PATH="%PATH%;C:/Rtools/gcc-4.6.3/bin;c:/Rtools/bin")

然后在出现以下提示时回答 "no":

"Install Build Tools Compiling C/C++ code for R requires installation of additional build tools. Do you want to install the additional tools now?"

没有独立尝试过这些操作,所以不确定自己是否可以解决问题

我发现确保所有这些都在我的路径中修复了它。我是在关闭 RStudio 的情况下完成的;之后我没有重启。

C:\Program Files\R\R-3.1.3\bin\x64
C:\Program Files\R\R-3.1.3\bin
C:\RBuildTools.2\bin
C:\RBuildTools.2\gcc-4.6.3\bin64
C:\RBuildTools.2\gcc-4.6.3\bin
C:\RBuildTools.2\gcc-4.6.3\i686-w64-mingw32\bin

这些在我的 Win7-64 位电脑上。 YMMV,我发布此内容主要是为了确保其他人在遇到相同问题时能够看到。

我遇到了同样的问题,我通过将 Rtools 目录添加到环境变量中解决了这个问题:

Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")