安装和运行 rcpp 时出错 [英] Error installing and running rcpp

查看:49
本文介绍了安装和运行 rcpp 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 R 很陌生,所以为一个愚蠢的问题道歉.我正在尝试让 rcpp 运行,但我陷入了 R 的无限循环,要求我重新安装 RTools.

I'm pretty new to R so apologies for a stupid question. I'm trying to get rcpp running but I'm stuck in an endless loop of R asking me to re-install RTools.

我大致遵循了这篇博文中的代码,尽管第一次关闭我手动安装了所有东西我随后重新安装了所有东西几次.我正在运行 Windows 7、R 版本 3.1.2、R Studio 版本 0.98.1091(并不是说这应该很重要)和 RTools 3.1.

I broadly followed the code in this blog post, although first time off I installed everything by hand & I've subsequently re-installed everything a few times over. I'm running Windows 7, R version 3.1.2, R Studio Version 0.98.1091 (not that this should matter much) and RTools 3.1.

我的控制台外观的编辑亮点如下:

An edited highlight of what my console looks like is as follows:

> 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.

此时会弹出一个对话框说:

At which point a dialog box pops up saying:

安装构建工具为 R 编译 C/C++ 代码需要安装额外的构建工具.是否要立即安装其他工具?

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.

And then I get directed to download and re-install RTools 3.1 from cran all over again.

我已经看到这可能是 PATH 变量的问题,但我尝试了各种方法,包括:

I've seen that this can be an issue with the PATH variable but I've tried various things including:

  1. PATH 变量中没有任何内容(额外的)
  2. 包括对 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;) 在 PATH 中.一次先用 RTools,一次先用 R
  3. 在 PATH 中仅包含对 RTools 的引用,作为初始安装文件指示我执行的操作.

任何关于尝试的想法都将被感激地接受!

Any ideas on things to try would be gratefully accepted!

编辑

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

Following Dirk's comment it looks like I might have a problem with how RTools is installed. I've followed the instructions from several blogs / tutorials on how to install RTools; all to no avail (yet!)

这个 GitHub 页面 提供了一些关于如何操作的说明安装并检查安装是否成功.我已经完成了所有检查(请参阅下面的控制台副本),看起来我已经安装了 RTools,但是当我再次尝试运行 evalCPP() 时,我得到了同样的错误就像之前指导我安装 RTools 一样.

This GitHub page gives some instructions on how install and check that the installation has worked. I've followed all the checks (see below for copy of the console) and it looks like I have a working install of RTools, but when I try to run evalCPP() again I get the same error as before directing me to install 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.我没有时间立即这样做,但会尝试一下,除非人们说这条路线不值得我花时间.

I've also had a look at Appendix D of R Installation and Admin. I can't see anything in here I've not already tried except for section D.4 which implies I might need to rebuild rcpp from source using my installed RTools. I don't have time to do this right away but will give it a try unless people say this route is not worth my time.

编辑 v2

所以我尝试从源代码构建 rcpp ......但这也不起作用.我从 CRAN Rcpp 包页面.在 R 控制台中,我现在得到:

So I tried building rcpp from source ... and that didn't work either. I downloaded both the package source and windows binaries from the CRAN Rcpp package page. In the R console I now get:

> 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)

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

I guess my active questions now boil down to:

  • 阅读上面的整个帖子,谁能告诉我如何解决问题,使其正常工作?或者,失败了...
  • 我可以运行哪些测试来检查我是否真的正确安装了 Rtools?我在互联网上找到的一切都表明我这样做:system('where make') 等等.但是,无法运行 evalCpp 或其他 rccp 函数的证据表明我不要.
  • 从源代码构建时我做错了什么?我应该尝试命令行选项吗?
  • Reading the whole of the post above can anyone tell me how to fix things so it just works? Or, failing that...
  • What tests can I run to check I really do have Rtools installed correctly? Everything I have found on the internet suggests I do: system('where make') etc. However, the evidence of being unable to run evalCpp or other rccp functions suggests I don't.
  • What am I doing wrong when building from source? Should I try the command line option?

编辑 v3

Running evalCpp with showOutput= TRUEverbose = TRUE 我想我已经将错误追踪回 R CMD SHLIB 不工作.我关注了这个博客,它展示了如何直接使用命令行 R.但是,当我到达 R CMD SHLIB sequence_examples.c 行时,执行只是直接跳到下一个命令行而不做任何事情,在目录中生成任何文件或抛出任何错误.我尝试在命令行运行 --help 选项,但得到同样的错误:

Running evalCpp with showOutput= TRUE and verbose = TRUE I think I've tracked the error back to R CMD SHLIB not working. I followed this blog, which shows how to work with the command line R directly. However when I get to the line R CMD SHLIB sequence_examples.c the execution just skips straight to the next command line without doing anything, generating any files in the directory or throwing any errors. I tried running the --help options at the command line but get the same sort of error:

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. for people reading the earlier code samples higher up this post I have changed a few things since those code snapshots:

  • 我已将 R 直接安装到 C:\R.它曾经在 C:\Program Files\R\ 中,但正如建议的那样,带有空格的文件路径可能会导致问题
  • 我在 C:\Rtools\ 下引用 Rtools 而不是 C:\RBuildTools\

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

Thanks for any suggestions, as ever

推荐答案

最终还是有点偏题.灵感来自 以下帖子,我查看了 ComSpec 环境变量.不太确定如何,但我已将其设置为 "cmd.exe".

In the end it was something a bit left-field. Inspired by the following post, I had a look at the ComSpec environment variable. Not quite sure how, but I had it set to "cmd.exe".

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

Removing the double quotes, so it said cmd.exe, and then rebooting fixed everything.

感谢所有尝试提供帮助的人.

Thanks to all who've tried to help.

这篇关于安装和运行 rcpp 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆