[英]Error installing and running rcpp
我對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.
此時彈出一個對話框說:
安裝構建工具為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
我還看了R安裝和管理員的附錄D. 我在這里看不到任何東西我除了第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)
我想我的積極問題現在歸結為:
system('where make')
等等。然而,無法運行evalCpp
或其他rccp功能的證據表明我沒有。 編輯v3
使用showOutput= TRUE
和verbose = TRUE
運行evalCpp
我想我已經將錯誤追溯到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>
對於那些閱讀早期代碼示例的人來說,這篇文章更高,我改變了一些事情,因為那些代碼快照:
感謝任何建議,一如既往
嘗試安裝Twitter的BreakoutDetection(也是用cpp編寫)時有同樣的無限循環問題
通過執行以下操作來修復
Sys.setenv(PATH="%PATH%;C:/Rtools/gcc-4.6.3/bin;c:/Rtools/bin")
然后在出現以下提示時回答“否”:
“安裝構建工具為R編譯C / C ++代碼需要安裝其他構建工具。是否要立即安裝其他工具?”
沒有獨立嘗試這些操作,所以不確定是否自己會解決問題
最后,它有點像左邊的東西。 受以下帖子的啟發,我看了一下ComSpec
環境變量。 不太確定如何,但我把它設置為"cmd.exe"
。
刪除雙引號,所以它說cmd.exe
,然后重新啟動修復一切。
感謝所有試圖幫助的人。
我發現確保所有這些都在我的路徑中修復它。 我用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,我主要發布這個,以確保其他人看到它,如果他們有同樣的問題。
我遇到了同樣的問題,我通過在env變量中添加Rtools dir來解決這個問題:
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.