stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.04k stars 264 forks source link

Error on stan when running 8school example #747

Open waa8128 opened 4 years ago

waa8128 commented 4 years ago

i just installed rstan in R, but it can not work.

i just followed the procedure 'Example 1: Eight Schools' in getting start.

The error is as follow.

library("rstan") Loading required package: StanHeaders Loading required package: ggplot2 rstan (Version 2.19.3, GitRev: 2e1f913d3ca3) For execution on a local, multicore CPU with excess RAM we recommend calling options(mc.cores = parallel::detectCores()). To avoid recompilation of unchanged Stan programs, we recommend calling rstan_options(auto_write = TRUE) For improved execution time, we recommend calling Sys.setenv(LOCAL_CPPFLAGS = '-march=corei7 -mtune=corei7') although this causes Stan to throw an error on a few processors. options(mc.cores = parallel::detectCores()) rstan_options(auto_write = TRUE) Sys.setenv(LOCAL_CPPFLAGS = '-march=corei7') schools_dat <- list(J = 8,

  • y = c(28, 8, -3, 7, -1, 1, 18, 12),
  • sigma = c(15, 10, 16, 11, 9, 11, 10, 18)) fit <- stan(file = '8schools.stan', data = schools_dat) Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! sh: C:/Program: No such file or directory make: *** [C:/PROGRA~1/R/R-35~1.3/etc/x64/Makeconf:215: file2201ad3164e.o] Error 127 In addition: Warning message: In system(cmd, intern = !verbose) : running command 'C:/PROGRA~1/R/R-35~1.3/bin/x64/R CMD SHLIB file2201ad3164e.cpp 2> file2201ad3164e.cpp.err.txt' had status 1 Error in sink(type = "output") : invalid connection

R version 3.5.3 Rtools version 3.5.0.4 Rstan version 2.19.3

RbHou commented 4 years ago

I run into a similar problem. Any advice is appreciated! R version is 3.6.1 Rtool version is 3.5 Rstan version is 2.19.3

system('g++ -v') Using built-in specs. COLLECT_GCC=C:\Rtools\mingw_64\bin\G__~1.EXE COLLECT_LTO_WRAPPER=C:/Rtools/mingw_64/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.3/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-4.9.3/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/home/Jeroen/mingw-gcc-4.9.3/x86_64-493-posix-seh-rt_v3-s/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-static --disable-shared --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static --with-mpc=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static --with-isl=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static --with-cloog=/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='x86_64-posix-seh, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/home/Jeroen/mingw-gcc-4.9.3/x86_64-493-posix-seh-rt_v3-s/mingw64/opt/include -I/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-zlib-static/include -I/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/home/Jeroen/mingw-gcc-4.9.3/x86_64-493-posix-seh-rt_v3-s/mingw64/opt/include -I/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-zlib-static/include -I/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/home/Jeroen/mingw-gcc-4.9.3/x86_64-493-posix-seh-rt_v3-s/mingw64/opt/lib -L/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-zlib-static/lib -L/home/Jeroen/mingw-gcc-4.9.3/prerequisites/x86_64-w64-mingw32-static/lib ' Thread model: posix gcc version 4.9.3 (x86_64-posix-seh, Built by MinGW-W64 project) [1] 0

fit <- stan(file = '8schools.stan', data = schools_dat) Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! g++.exe: error: Files/R/R-3.6.1/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory g++.exe: error: Files/R/R-3.6.1/library/StanHeaders/include: No such file or directory g++.exe: error: Files/R/R-3.6.1/library/RcppEigen/include: No such file or directory make: *** [D:/PROGRA~1/R/R-36~1.1/etc/x64/Makeconf:215: file23fc382531e9.o] Error 1 此外: Warning messages: 1: In readLines(file, warn = TRUE) : 读'C:\Users\DELL\Desktop\siteAmpModelJapan\RStan\8schools.stan'时最后一行未遂 2: In system(cmd, intern = !verbose) : 运行命令'D:/PROGRA~1/R/R-36~1.1/bin/x64/R CMD SHLIB file23fc382531e9.cpp 2> file23fc382531e9.cpp.err.txt'的状态是1 Error in sink(type = "output") : 链结不对

From verbose=TRUE, the compiler command is: c:/Rtools/mingw_64/bin/g++ -std=gnu++11 -I"D:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG -I"D:/Program Files/R/R-3.6.1/library/Rcpp/include/" -I"D:/Program Files/R/R-3.6.1/library/RcppEigen/include/" -I"D:/Program Files/R/R-3.6.1/library/RcppEigen/include/unsupported" -I"D:/Program Files/R/R-3.6.1/library/BH/include" -I"D:/Program Files/R/R-3.6.1/library/StanHeaders/include/src/" -I"D:/Program Files/R/R-3.6.1/library/StanHeaders/include/" -I"D:/Program Files/R/R-3.6.1/library/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=native -include D:/Program Files/R/R-3.6.1/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I D:/Program Files/R/R-3.6.1/library/StanHeaders/include -I D:/Program Files/R/R-3.6.1/library/RcppEigen/include -O3 -march=corei7 -mtune=corei7 -c file1bd8412969f8.cpp -o file1bd8412969f8.o g++.exe: error: Files/R/R-3.6.1/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory g++.exe: error: Files/R/R-3.6.1/library/StanHeaders/include: No such file or directory g++.exe: error: Files/R/R-3.6.1/library/RcppEigen/include: No such file or directory

it seems there is something wrong with the compiler option. However, I cannot figure it out.