我对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.
Run Code Online (Sandbox Code Playgroud)
此时弹出一个对话框说:
安装构建工具为R编译C/C++代码需要安装其他构建工具.您想立即安装其他工具吗?
然后我被指示从头再次下载并重新安装RTools 3.1.
我已经看到这可能是PATH变量的问题,但我尝试了各种各样的事情,包括:
任何关于尝试的事情的想法都将被感激地接受!
编辑
根据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
Run Code Online (Sandbox Code Playgroud)
我也看了一下附录d R安装过程中和管理的.我在这里看不到任何东西我除了第D.4节之外我还没有尝试过,这意味着我可能需要使用我安装的RTools从源代码重建rcpp.我没有时间立即这样做,但除非人们说这条路线不值得我花时间,否则会尝试一下.
编辑v2
所以我尝试从源代码构建rcpp ......这也不起作用.我从CRAN Rcpp包页面下载了包源代码和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)
Run Code Online (Sandbox Code Playgroud)
我想我的积极问题现在归结为:
system('where make')等等.然而,无法运行evalCpp或其他rccp功能的证据表明我没有.编辑v3
运行evalCpp时showOutput= TRUE,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>
Run Code Online (Sandbox Code Playgroud)
对于那些阅读早期代码示例的人来说,这篇文章更高,我改变了一些事情,因为那些代码快照:
感谢任何建议,一如既往
小智 6
尝试安装Twitter的BreakoutDetection(也是用cpp编写)时有同样的无限循环问题
通过执行以下操作来修复
Sys.setenv(PATH="%PATH%;C:/Rtools/gcc-4.6.3/bin;c:/Rtools/bin")
Run Code Online (Sandbox Code Playgroud)
然后在出现以下提示时回答"否":
"安装构建工具为R编译C/C++代码需要安装其他构建工具.是否要立即安装其他工具?"
没有独立尝试这些操作,所以不确定是否自己会解决问题