[英]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变量的问题,但我尝试了各种各样的事情,包括:
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: 我想我的积极问题现在归结为:
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功能的证据表明我没有。 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= TRUE
和verbose = 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: 对于那些阅读早期代码示例的人来说,这篇文章更高,我改变了一些事情,因为那些代码快照:
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.