Rstan / Rcpp与file29e283457dac.cpp的连接问题

时间:2020-07-07 00:07:38

标签: r rcpp stan rstan

我正在尝试在R / RStudio中使用Stan建模。

我在此链接上使用了代码(示例1):https://rdrr.io/cran/rstan/man/stan.html

library(rstan)
scode <- "
parameters {
real y[2]; 
} 
model {
y[1] ~ normal(0, 1);
y[2] ~ double_exponential(0, 2);
} 
"
fit1 <- stan(model_code = scode, iter = 10, verbose = FALSE) 
print(fit1)
fit2 <- stan(fit = fit1, iter = 10000, verbose = FALSE) 

## using as.array on the stanfit object to get samples 
a2 <- as.array(fit2)

## extract samples as a list of arrays
e2 <- extract(fit2, permuted = FALSE)

我收到以下错误:

文件错误(con,“ r”):无法打开连接 另外:警告消息: 1:在系统中(cmd,intern =!verbose): 运行命令'C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file29e283457dac.cpp 2> file29e283457dac.cpp.err.txt'的状态为1 2:在文件中(con,“ r”): 无法打开文件'file29e283457dac.cpp.err.txt':无此类文件或目录 接收器错误(类型为“输出”):连接无效

Rstan devtools信息

devtools::session_info("rstan")
- Session info ---------------------------------------------------------------------------
 setting  value                       
 version  R version 4.0.2 (2020-06-22)
 os       Windows >= 8 x64            
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       America/Los_Angeles         
 date     2020-07-06                  

- Packages -------------------------------------------------------------------------------
 ! package      * version   date       lib source        
   assertthat     0.2.1     2019-03-21 [1] CRAN (R 4.0.2)
   backports      1.1.7     2020-05-13 [1] CRAN (R 4.0.0)
   BH             1.72.0-3  2020-01-08 [1] CRAN (R 4.0.0)
   callr          3.4.3     2020-03-28 [1] CRAN (R 4.0.2)
   checkmate      2.0.0     2020-02-06 [1] CRAN (R 4.0.2)
   cli            2.0.2     2020-02-28 [1] CRAN (R 4.0.2)
   colorspace     1.4-1     2019-03-18 [1] CRAN (R 4.0.2)
   crayon         1.3.4     2017-09-16 [1] CRAN (R 4.0.2)
   desc           1.2.0     2018-05-01 [1] CRAN (R 4.0.2)
   digest         0.6.25    2020-02-23 [1] CRAN (R 4.0.2)
   ellipsis       0.3.1     2020-05-15 [1] CRAN (R 4.0.2)
   evaluate       0.14      2019-05-28 [1] CRAN (R 4.0.2)
   fansi          0.4.1     2020-01-08 [1] CRAN (R 4.0.2)
   farver         2.0.3     2020-01-16 [1] CRAN (R 4.0.2)
   ggplot2        3.3.2     2020-06-19 [1] CRAN (R 4.0.2)
   glue           1.4.1     2020-05-13 [1] CRAN (R 4.0.2)
   gridExtra      2.3       2017-09-09 [1] CRAN (R 4.0.2)
   gtable         0.3.0     2019-03-25 [1] CRAN (R 4.0.2)
   inline         0.3.15    2018-05-18 [1] CRAN (R 4.0.2)
   isoband        0.2.2     2020-06-20 [1] CRAN (R 4.0.2)
   labeling       0.3       2014-08-23 [1] CRAN (R 4.0.0)
   lattice        0.20-41   2020-04-02 [2] CRAN (R 4.0.2)
   lifecycle      0.2.0     2020-03-06 [1] CRAN (R 4.0.2)
   loo            2.2.0     2019-12-19 [1] CRAN (R 4.0.2)
   magrittr       1.5       2014-11-22 [1] CRAN (R 4.0.2)
   MASS           7.3-51.6  2020-04-26 [2] CRAN (R 4.0.2)
   Matrix         1.2-18    2019-11-27 [2] CRAN (R 4.0.2)
   matrixStats    0.56.0    2020-03-13 [1] CRAN (R 4.0.2)
   mgcv           1.8-31    2019-11-09 [2] CRAN (R 4.0.2)
   munsell        0.5.0     2018-06-12 [1] CRAN (R 4.0.2)
   nlme           3.1-148   2020-05-24 [2] CRAN (R 4.0.2)
   pillar         1.4.4     2020-05-05 [1] CRAN (R 4.0.2)
   pkgbuild       1.0.8     2020-05-07 [1] CRAN (R 4.0.2)
   pkgconfig      2.0.3     2019-09-22 [1] CRAN (R 4.0.2)
   pkgload        1.1.0     2020-05-29 [1] CRAN (R 4.0.2)
   praise         1.0.0     2015-08-11 [1] CRAN (R 4.0.2)
   prettyunits    1.1.1     2020-01-24 [1] CRAN (R 4.0.2)
   processx       3.4.3     2020-07-05 [1] CRAN (R 4.0.2)
   ps             1.3.3     2020-05-08 [1] CRAN (R 4.0.2)
   R6             2.4.1     2019-11-12 [1] CRAN (R 4.0.2)
   RColorBrewer   1.1-2     2014-12-07 [1] CRAN (R 4.0.0)
   Rcpp           1.0.5     2020-07-06 [1] CRAN (R 4.0.2)
   RcppEigen      0.3.3.7.0 2019-11-16 [1] CRAN (R 4.0.2)
 D RcppParallel   5.0.2     2020-06-24 [1] CRAN (R 4.0.2)
   rlang          0.4.6     2020-05-02 [1] CRAN (R 4.0.2)
   rprojroot      1.3-2     2018-01-03 [1] CRAN (R 4.0.2)
   rstan          2.19.3    2020-02-11 [1] CRAN (R 4.0.2)
   rstudioapi     0.11      2020-02-07 [1] CRAN (R 4.0.2)
   scales         1.1.1     2020-05-11 [1] CRAN (R 4.0.2)
   StanHeaders    2.21.0-5  2020-06-09 [1] CRAN (R 4.0.2)
   testthat       2.3.2     2020-03-02 [1] CRAN (R 4.0.2)
   tibble         3.0.1     2020-04-20 [1] CRAN (R 4.0.2)
   utf8           1.1.4     2018-05-24 [1] CRAN (R 4.0.2)
   vctrs          0.3.1     2020-06-05 [1] CRAN (R 4.0.2)
   viridisLite    0.3.0     2018-02-01 [1] CRAN (R 4.0.2)
   withr          2.2.0     2020-04-20 [1] CRAN (R 4.0.2)

[1] C:/Users/Wesley Engers/Documents/R/win-library/4.0
[2] C:/Program Files/R/R-4.0.2/library

 D -- DLL MD5 mismatch, broken installation.

我正在运行Windows版本R为4.0.2(2020-06-22)的计算机。我尝试卸载并重新安装RcppParallel,但似乎没有帮助。让我知道您是否还需要其他任何信息 信息。任何有关如何解决此错误的帮助将不胜感激!

编辑:解决Ben的评论。在此之前有一堆代码,但是我相信这是错误的部分。通过stan函数以verbose = TRUE的输出。

Compilation argument:
 C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file68206e4a2c56.cpp 2> file68206e4a2c56.cpp.err.txt 
"C:/rtools40/mingw64/bin/"g++  -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG   -I"C:/Users/Wesley Engers/Documents/R/win-library/4.0/Rcpp/include/"  -I"C:/Users/Wesley Engers/Documents/R/win-library/4.0/RcppEigen/include/"  -I"C:/Users/Wesley Engers/Documents/R/win-library/4.0/RcppEigen/include/unsupported"  -I"C:/Users/Wesley Engers/Documents/R/win-library/4.0/BH/include" -I"C:/Users/Wesley Engers/Documents/R/win-library/4.0/StanHeaders/include/src/"  -I"C:/Users/Wesley Engers/Documents/R/win-library/4.0/StanHeaders/include/"  -I"C:/Users/Wesley Engers/Documents/R/win-library/4.0/rstan/include" -DEIGEN_NO_DEBUG  -D_REENTRANT  -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp  -std=c++1y    -march=corei7 -mtune=corei7   -include C:/Users/Wesley Engers/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I "C:/Users/Wesley Engers/Documents/R/win-library/4.0/StanHeaders/include" -I "C:/Users/Wesley E... <truncated>
g++.exe: error: Engers/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory
make: *** [C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf:229: file68206e4a2c56.o] Error 1
Error in file(con, "r") : cannot open the connection

更新2:这是我在安装Ben建议的StanHeaders之后得到的错误。

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: filece9460ea6ca8.o:filece9460ea6ca8.cpp:(.text+0x9d7): undefined reference to `rstan::stan_fit::stan_fit(SEXPREC*, int)'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: filece9460ea6ca8.o:filece9460ea6ca8.cpp:(.text+0xabc): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: filece9460ea6ca8.o:filece9460ea6ca8.cpp:(.text+0xafe): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: filece9460ea6ca8.o:filece9460ea6ca8.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D1Ev[_ZN3tbb8internal26task_scheduler_

0 个答案:

没有答案