我对 R 还很陌生,所以对一个愚蠢的问题表示歉意。我正在尝试让 rcpp 运行,但我陷入了 R 的无限循环,要求我重新安装 RTools。
我大致遵循了以下代码这篇博文,虽然第一次休息时我手动安装了所有东西,随后我又重新安装了几次。我正在运行 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.
这时会弹出一个对话框,提示:
安装构建工具
为 R 编译 C/C++ 代码需要安装额外的构建工具。
您想现在安装附加工具吗?
然后我被指示再次从 cran 下载并重新安装 RTools 3.1。
我发现这可能是 PATH 变量的问题,但我尝试了各种方法,包括:
- PATH 变量中没有任何(额外的)内容
- 包括对 R (C:\Program Files\R\R-3.1.2\bin\x64) 和 RTools (C:\RBuildTools\3.1\bin;C:\RBuildTools\3.1\gcc-4.6.3\bin) 的引用;) 在路径中。先用 RTools 一次,先用 R 一次
- 按照初始安装文件的指示,在 PATH 中仅包含对 RTools 的引用。
任何有关尝试的想法将不胜感激!
EDIT
根据 Dirk 的评论,我似乎对 RTools 的安装方式有疑问。我已经按照几个博客/教程中关于如何安装 RTools 的说明进行操作;一切都无济于事(还!)
这个 GitHub 页面提供了一些有关如何安装和检查安装是否有效的说明。我已经遵循了所有检查(请参阅下面的控制台副本),看起来我已经安装了 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
我也看过R 安装和管理附录 D。我在这里看不到任何我还没有尝试过的东西,除了D.4 节这意味着我可能需要使用我安装的 RTools 从源代码重建 rcpp。我没有时间立即执行此操作,但会尝试一下,除非人们说这条路线不值得我花时间。
EDIT v2
所以我尝试从源代码构建 rcpp ...但这也不起作用。我从以下位置下载了包源代码和 Windows 二进制文件CRAN Rcpp 包页面。在 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)
我想我现在的活跃问题可以归结为:
- 阅读上面的整篇文章,谁能告诉我如何解决问题,使其正常工作?或者,如果失败的话...
- 我可以运行哪些测试来检查我是否确实正确安装了 Rtools?我在互联网上找到的所有内容都表明我这样做:
system('where make')
等等。但是,无法运行的证据evalCpp
或其他 rccp 函数表明我不这样做。
- 从源代码构建时我做错了什么?我应该尝试命令行选项吗?
EDIT v3
Running evalCpp
with showOutput= TRUE
and verbose = TRUE
我想我已经将错误追溯到R CMD SHLIB
不工作。我跟着这个博客,它展示了如何直接使用命令行 R。然而当我到达终点线时R CMD SHLIB sequence_examples.c
执行只是直接跳到下一个命令行,不执行任何操作,在目录中生成任何文件或引发任何错误。我尝试运行--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>
注意:对于阅读本文前面的早期代码示例的人们,自这些代码快照以来我已经更改了一些内容:
- 我已将 R 直接安装到 C:\R 中。它曾经位于 C:\Program Files\R\ 中,但正如建议的那样,带有空格的文件路径可能会导致问题
- 我引用的是 C:\Rtools\ 下的 Rtools,而不是 C:\RBuildTools\
一如既往,感谢您的任何建议