简体   繁体   English

安装和运行rcpp时出错

[英]Error installing and running rcpp

I'm pretty new to R so apologies for a stupid question. 我对R很陌生,所以对一个愚蠢的问题道歉。 I'm trying to get rcpp running but I'm stuck in an endless loop of R asking me to re-install RTools. 我正在尝试让rcpp运行,但我陷入无休止的R循环中,要求我重新安装RTools。

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. 我正在运行Windows 7,R版本3.1.2,R Studio版本0.98.1091(不是这应该很重要)和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: 此时弹出一个对话框说:

Install Build Tools Compiling C/C++ code for R requires installation of additional build tools. 安装构建工具为R编译C / C ++代码需要安装其他构建工具。 Do you want to install the additional tools now? 您想立即安装其他工具吗?

And then I get directed to download and re-install RTools 3.1 from cran all over again. 然后我被指示从头再次下载并重新安装RTools 3.1。

I've seen that this can be an issue with the PATH variable but I've tried various things including: 我已经看到这可能是PATH变量的问题,但我尝试了各种各样的事情,包括:

  1. Nothing (extra) in the PATH variable PATH变量中没有(额外的)
  2. Including both references to R (C:\\Program Files\\R\\R-3.1.2\\bin\\x64) and RTools (C:\\RBuildTools\\3.1\\bin;C:\\RBuildTools\\3.1\\gcc-4.6.3\\bin;) in the 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)的引用;)在PATH中。 Once with RTools first, once with R first 一次使用RTools,一次使用R first
  3. Including just a reference to RTools in the PATH as the initial install file directed me to do. 在PATH中只包含对RTools的引用,作为初始安装文件指示我做。

Any ideas on things to try would be gratefully accepted! 任何关于尝试的事情的想法都将被感激地接受!

EDIT 编辑

Following Dirk's comment it looks like I might have a problem with how RTools is installed. 根据Dirk的评论,看起来我可能对如何安装RTools有疑问。 I've followed the instructions from several blogs / tutorials on how to install RTools; 我已经按照几个博客/教程中有关如何安装RTools的说明进行操作; all to no avail (yet!) 一切都没有用(还是!)

This GitHub page gives some instructions on how install and check that the installation has worked. 此GitHub页面提供了有关如何安装和检查安装是否有效的一些说明。 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. 我已经按照所有检查(见下面的控制台副本)看起来我有一个工作安装的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

I've also had a look at Appendix D of R Installation and Admin . 我还看了R安装和管理员的附录D. 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. 我在这里看不到任何东西我除了第D.4节之外我还没有尝试过,这意味着我可能需要使用我安装的RTools从源代码重建rcpp。 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. 我没有时间立即这样做,但除非人们说这条路线不值得我花时间,否则会试一试。

EDIT v2 编辑v2

So I tried building rcpp from source ... and that didn't work either. 所以我尝试从源代码构建rcpp ......这也不起作用。 I downloaded both the package source and windows binaries from the CRAN Rcpp package page . 我从CRAN Rcpp包页面下载了包源代码和Windows二进制文件。 In the R console I now get: 在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)

I guess my active questions now boil down to: 我想我的积极问题现在归结为:

  • 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? 我可以运行哪些测试来检查我是否确实安装了Rtools? 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. 我在互联网上发现的一切都表明我做了: system('where make')等等。然而,无法运行evalCpp或其他rccp功能的证据表明我没有。
  • What am I doing wrong when building from source? 从源代码构建时我做错了什么? Should I try the command line option? 我应该尝试命令行选项吗?

EDIT v3 编辑v3

Running evalCpp with showOutput= TRUE and verbose = TRUE I think I've tracked the error back to R CMD SHLIB not working. 使用showOutput= TRUEverbose = TRUE运行evalCpp我想我已经将错误追溯到R CMD SHLIB无效。 I followed this blog , which shows how to work with the command line R directly. 我按照这个博客 ,展示了如何直接使用命令行R. 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. 然而,当我到达R CMD SHLIB sequence_examples.c ,执行只是直接跳到下一个命令行而不做任何事情,生成目录中的任何文件或抛出任何错误。 I tried running the --help options at the command line but get the same sort of error: 我尝试在命令行运行--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>

NB for people reading the earlier code samples higher up this post I have changed a few things since those code snapshots: 对于那些阅读早期代码示例的人来说,这篇文章更高,我改变了一些事情,因为那些代码快照:

  • I've installed R directly into C:\\R. 我已经将R直接安装到C:\\ R中。 It used to be in C:\\Program Files\\R\\ but as has been suggested file paths with spaces in can cause problems 它曾经在C:\\ Program Files \\ R \\中,但是已经建议带有空格的文件路径会导致问题
  • I'm referencing Rtools under C:\\Rtools\\ and not C:\\RBuildTools\\ 我在C:\\ Rtools \\下引用Rtools而不是C:\\ RBuildTools \\

Thanks for any suggestions, as ever 感谢任何建议,一如既往

Had the same endless loop issue when trying to install Twitter's BreakoutDetection (which is also written in cpp) 尝试安装Twitter的BreakoutDetection(也是用cpp编写)时有同样的无限循环问题

fixed by executing the following 通过执行以下操作来修复

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

and then answering "no" when presented with the following prompt: 然后在出现以下提示时回答“否”:

"Install Build Tools Compiling C/C++ code for R requires installation of additional build tools. Do you want to install the additional tools now?" “安装构建工具为R编译C / C ++代码需要安装其他构建工具。是否要立即安装其他工具?”

Didn't try these actions independently so not sure if either on their own would have fixed the issue 没有独立尝试这些操作,所以不确定是否自己会解决问题

In the end it was something a bit left-field. 最后,它有点像左边的东西。 Inspired by the following post , I had a look at the ComSpec environment variable. 以下帖子的启发,我看了一下ComSpec环境变量。 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. 删除双引号,所以它说cmd.exe ,然后重新启动修复一切。

Thanks to all who've tried to help. 感谢所有试图帮助的人。

I found that ensuring all of these were in my path fixed it. 我发现确保所有这些都在我的路径中修复它。 I did this with RStudio closed; 我用RStudio关闭了这个; I didn't reboot after. 之后我没有重启。

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

These are on my Win7-64bit computer. 这些都在我的Win7-64bit计算机上。 YMMV, and I'm mostly posting this to ensure others see it if they are having the same issue. YMMV,我主要发布这个,以确保其他人看到它,如果他们有同样的问题。

我遇到了同样的问题,我通过在env变量中添加Rtools dir来解决这个问题:

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

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

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