2015-02-06 140 views
7

我對R很新,所以對於一個愚蠢的問題表示歉意。我試圖讓rcpp運行,但是我陷入了無休止的R環中,要求我重新安裝RTools。安裝和運行rcpp時出錯

我大致遵循了this blog post中的代碼,雖然第一次我手動安裝了所有東西&我後來重新安裝了幾次。我運行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. 

此時一個對話框彈出說:

Install Build Tools Compiling C/C++ code for R requires installation of additional build tools. Do you want to install the additional tools now?

然後我得到指示下載並重新從頭再來安裝RTools 3.1。

我已經看到了,這可能是與PATH變量的問題,但我已經試過各種事情,包括:在PATH變量

  • 包括以R(兩個引用

    1. 沒有(額外) 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一次
    2. 只包含對PATH中RTools的引用,因爲初始安裝文件指示我這樣做。

    任何想嘗試的事情都會被感激地接受!

    編輯

    隨着德克的評論,它看起來像我可能有RTools是如何安裝的問題。我已經按照幾個博客/教程的指示瞭解如何安裝RTools;所有無濟於事(還沒有!)

    This GitHub page給出了一些關於如何安裝和檢查安裝工作的說明。我已經完成了所有的檢查(見下面的控制檯副本),看起來我有一個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 
    

    我也看過Appendix D of R Installation and Admin。我在這裏看不到任何東西,除了section D.4之外,我還沒有嘗試過,這意味着我可能需要使用我安裝的RTools從源重建rcpp。我沒有時間做這件事,但會試一試,除非人們說這條路線不值得我花時間。

    編輯V2

    所以,我想建築RCPP從源頭......這也不能工作。我從the CRAN Rcpp package page下載了軟件包源代碼和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) 
    

    我想我主動的問題現在歸結爲:

    • 閱讀整個後的上述誰能告訴我怎麼解決的事情,所以它只是工作?或者,做不到這一點...
    • 我可以運行什麼測試,以檢查我確實有正確安裝Rtools?我在互聯網上發現的一切都表明我的確如此:system('where make')等。但是,無法運行evalCpp或其他rccp函數的證據表明我沒有。
    • 從源代碼構建時我做錯了什麼?我應該嘗試命令行選項嗎?

    編輯V3

    運行evalCppshowOutput= TRUEverbose = TRUE我想我已經跟蹤誤差回R CMD SHLIB不工作。我遵循this blog,它顯示瞭如何直接使用命令行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> 
    

    N.B.人們閱讀前面的代碼示例上漲這一職位,因爲這些代碼的快照我已經改變了一些東西:

    • 我已經安裝了[R直接進入C:\ r。它曾經在C:\ Program Files \ R \中,但是正如已經建議的文件路徑中有空格可能會導致問題
    • 我在C:\ Rtools \下引用Rtools而不是C:\ RBuildTools \

    感謝您的任何建議,一如既往

  • +1

    這是記錄在許多地方,包括R手冊,以及大量的教程你試過的東西不適合你,也許試試另一個? Rcpp不需要特別的,但你必須有Rtools的工作。 – 2015-02-07 02:17:54

    +0

    嘗試不同版本的Rtools。如果您使用的是Rtools32.exe,那麼請嘗試卸載它,並通過從http://cran.r-project.org/bin/windows/Rtools/下載Rtools31.exe並運行剛剛下載的安裝程序來安裝Rtools31.exe。確保啓動一個新的R會話,並且如果您從cmd會話啓動R,然後重新啓動。 – 2015-02-07 13:55:39

    +0

    不幸的是,我已經嘗試過Rtools32.exe – 2015-02-07 16:08:58

    回答

    0

    最後它有點左偏。受following post的啓發,我查看了ComSpec環境變量。不太確定如何,但我已將它設置爲"cmd.exe"

    卸下雙引號,所以說cmd.exe,然後重新啓動固定一切。

    感謝所有誰一直試圖幫助。

    6

    只好嘗試安裝Twitter的BreakoutDetection(也寫在CPP)

    通過時所提出的執行以下

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

    ,然後回答「否」固定在同一無限循環問題以下提示:

    「安裝生成工具編譯C/C++代碼的R需要安裝額外的構建工具是否要立即安裝額外的工具?「

    沒有嘗試這些動作獨立所以不知道如果任其自生自滅將有固定的問題

    0

    我發現,保證所有的這些都是在我的道路修好了我這樣做是與RStudio關閉。我沒有重新啓動後。

    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 
    

    這些都是我Win7-64bit計算機上。YMMV,以及我主要發佈是爲了確保其他人看到它,如果他們有同樣的問題。