Sadly I’m having some trouble getting that to compile from source. Variations of the errors and warnings I see all the time are:
J:/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/scal/meta/require_generics.hpp:736:53: warning: variadic
templates only available with -std=c++11 or -std=gnu++11
template <template <class...> class TypeCheck, class... Check>
^
J:/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/scal/meta/require_generics.hpp:737:1: error: expected
unqualified-id before 'using'
using require_all_not_std_vector_st
^
And it ends with
make: *** [C:/PROGRA~1/R/R-36~1.2/etc/i386/Makeconf:215: sparse_extractors.o] Error 1
ERROR: compilation failed for package 'rstan'
* removing 'J:/Documents/R/win-library/3.6/rstan'
* restoring previous 'J:/Documents/R/win-library/3.6/rstan'
Error: Failed to install 'rstan' from GitHub:
(converted from warning) installation of package
‘C:/Users/maum/AppData/Local/Temp/RtmpIXM05M/file3e88678f6169/rstan_2.21.1.tar.gz’ had non-zero exit status
In addition: Warning message:
In utils::untar(tarfile, ...) :
‘tar.exe -xf "C:\Users\maum\AppData\Local\Temp\RtmpIXM05M\file3e886f114dd6.tar.gz" -C
"C:/Users/maum/AppData/Local/Temp/RtmpIXM05M/remotes3e88eac4bec"’ returned error code 1
Unfortunately I have no idea what these errors mean - any advice is greatly appreciated.
P.S. the installation errors and warnings go on for multiple screens - let me know if you want me to capture them entirely.
Hold on, for whatever reason, using rstan 2.19.2 with StanHeaders 2.21.0-1 is now working (mostly) as expected. I’ll do some more testing, but if you don’t hear from me, please don’t spend any time on this anymore! :-)
Unfortunately I seem to have celebrated a bit too early. Some of the simpler Stan models (i.e. 8 schools) compile and sample just fine, but a slightly more complex model gives this error:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created!
C:\Users\maum\AppData\Local\Temp\cc553bQO.s: Assembler messages:
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:8510: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:8512: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:17711: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:88036: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:88038: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:88040: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:121760: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:186054: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.s:188560: Error: invalid register for .seh_savexmm
C:\Users\maum\AppData\Local\Temp\cc553bQO.
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command 'C:/PROGRA~1/R/R-36~1.2/bin/x64/R CMD SHLIB file2828102563db.cpp 2> file2828102563db.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection
Does this seem related?
To be precise this shows up when trying to compile the model with stan_model().
Things like that are usually due to having -mtune=native -march=native and the compiler misdiagnosing the processor. If you have that in CXX11FLAGS or something, try removing it.
Hi. Not sure whether it is acceptable to use this thread but I am experiencing issues compiling Stan models. I installed RStan without any issues.
Win 10, 64 bit, R 3.6.2, Rtools 3.5.0.4
However, when I try to run the following command:
example(stan_model, run.dontrun = TRUE)
I get the following errors:
g++.exe: error: Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory
g++.exe: error: Files/R/R-3.6.2/library/StanHeaders/include: No such file or directory
g++.exe: error: Files/R/R-3.6.2/library/RcppEigen/include: No such file or directory
and the errors complain that
Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp
doesn’t exist, etc. The paths have been mangled.
Needless to say, these files and directories all exist on my machine.
Is there a way to force the paths to be properly quoted? And would that solve the problem?
Thank you very much for your prompt response. I re-installed StanHeaders using the command you provided and the version is now 2.19.0. I no longer get the previous errors about missing files, which is great. However, compilation still fails, this time with the following error message. My installed version of RStan is at 2.19.2.
Again, any help will be much appreciated. Thanks.
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! file26c46c0d4248.cpp:66:40: error: expected template-name before '<' token
: public stan::model::model_base_crtp<model26c4290627dd_lm> {
^
file26c46c0d4248.cpp:66:40: error: expected '{' before '<' token
file26c46c0d4248.cpp:66:40: error: expected unqualified-id before '<' token
In file included from C:/Program Files/R/R-3.6.2/library/BH/include/boost/winapi/time.hpp:13:0,
from C:/Program Files/R/R-3.6.2/library/BH/include/boost/date_time/microsec_time_clock.hpp:24,
from C:/Program Files/R/R-3.6.2/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:11,
from C:/Program Files/R/R-3.6.2/library/rstan/include/rstan/stan_fit.hpp:13,
from C:/Program Files/R/R-3.6.2/library/rstan/include/rstan/rstaninc.hpp:3,
from file26c46c0d4248.cpp:631:
C:/Program Files/R/R-3.6.2/library/BH/include/boos
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command 'C:/PROGRA~1/R/R-36~1.2/bin/x64/R CMD SHLIB file26c46c0d4248.cpp 2> file26c46c0d4248.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection
Deleted Rstan and tried to install from source but unfortunately that failed with many errors. Here are the first few lines of output from the build process
* installing *source* package 'rstan' ...
** package 'rstan' successfully unpacked and MD5 sums checked
** using staged installation
** libs
"C:\Rtools\mingw_64\bin\g++.exe" -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"../inst/include" -I"." -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Program Files/R/R-3.6.2/library/Rcpp/include" -I"C:/Program Files/R/R-3.6.2/library/RcppEigen/include" -I"C:/Program Files/R/R-3.6.2/library/BH/include" -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include" -O3 -march=native -mtune=native -c sparse_extractors.cpp -o sparse_extractors.o
"C:\Rtools\mingw_64\bin\g++.exe" -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"../inst/include" -I"." -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Program Files/R/R-3.6.2/library/Rcpp/include" -I"C:/Program Files/R/R-3.6.2/library/RcppEigen/include" -I"C:/Program Files/R/R-3.6.2/library/BH/include" -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include" -O3 -march=native -mtune=native -c misc.cpp -o misc.o
"C:\Rtools\mingw_64\bin\g++.exe" -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"../inst/include" -I"." -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Program Files/R/R-3.6.2/library/Rcpp/include" -I"C:/Program Files/R/R-3.6.2/library/RcppEigen/include" -I"C:/Program Files/R/R-3.6.2/library/BH/include" -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include" -O3 -march=native -mtune=native -c stanc.cpp -o stanc.o
"C:\Rtools\mingw_64\bin\g++.exe" -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"../inst/include" -I"." -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Program Files/R/R-3.6.2/library/Rcpp/include" -I"C:/Program Files/R/R-3.6.2/library/RcppEigen/include" -I"C:/Program Files/R/R-3.6.2/library/BH/include" -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include" -O3 -march=native -mtune=native -c init.cpp -o init.o
"C:\Rtools\mingw_64\bin\g++.exe" -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"../inst/include" -I"." -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Program Files/R/R-3.6.2/library/Rcpp/include" -I"C:/Program Files/R/R-3.6.2/library/RcppEigen/include" -I"C:/Program Files/R/R-3.6.2/library/BH/include" -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include" -O3 -march=native -mtune=native -c pointer-tools.cpp -o pointer-tools.o
"C:\Rtools\mingw_64\bin\g++.exe" -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"../inst/include" -I"." -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Program Files/R/R-3.6.2/library/Rcpp/include" -I"C:/Program Files/R/R-3.6.2/library/RcppEigen/include" -I"C:/Program Files/R/R-3.6.2/library/BH/include" -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include" -O3 -march=native -mtune=native -c chains.cpp -o chains.o
In file included from C:/Program Files/R/R-3.6.2/library/BH/include/boost/spirit/include/phoenix_limits.hpp:11:0,
from C:/Program Files/R/R-3.6.2/library/BH/include/boost/spirit/home/support/meta_compiler.hpp:16,
from C:/Program Files/R/R-3.6.2/library/BH/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from C:/Program Files/R/R-3.6.2/library/BH/include/boost/spirit/home/qi/action/action.hpp:14,
from C:/Program Files/R/R-3.6.2/library/BH/include/boost/spirit/home/qi/action.hpp:14,
from C:/Program Files/R/R-3.6.2/library/BH/include/boost/spirit/home/qi.hpp:14,
from C:/Program Files/R/R-3.6.2/library/BH/include/boost/spirit/include/qi.hpp:16,
from ./stan/lang/grammars/whitespace_grammar.hpp:4,
from ./stan/lang/grammars/program_grammar.hpp:6,
from C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src/stan/lang/parser.hpp:5,
from C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src/stan/lang/compiler.hpp:7,
from stanc.cpp:22:
C:/Program Files/R/R-3.6.2/library/BH/include/boost/phoenix/core/limits.hpp:44:0: warning: "BOOST_PHOENIX_NO_VARIADIC_EXPRESSION" redefined
# define BOOST_PHOENIX_NO_VARIADIC_EXPRESSION
^
<command-line>:0:0: note: this is the location of the previous definition
"C:\Rtools\mingw_64\bin\g++.exe" -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG -I"../inst/include" -I"." -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Program Files/R/R-3.6.2/library/Rcpp/include" -I"C:/Program Files/R/R-3.6.2/library/RcppEigen/include" -I"C:/Program Files/R/R-3.6.2/library/BH/include" -I"C:/Program Files/R/R-3.6.2/library/StanHeaders/include" -O3 -march=native -mtune=native -c stan/lang/ast_def.cpp -o stan/lang/ast_def.o
In file included from chains.cpp:19:0:
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp: In function 'typename boost::math::tools::promote_args<T>::type stan::math::mean(const std::vector<T>&)':
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:63: error: an array reference cannot appear in a constant-expression
Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>> m(&v[0], v.size());
^
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:63: error: '&' cannot appear in a constant-expression
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:68: error: '.' cannot appear in a constant-expression
Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>> m(&v[0], v.size());
^
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:73: error: a function call cannot appear in a constant-expression
Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>> m(&v[0], v.size());
^
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:74: error: a function call cannot appear in a constant-expression
Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>> m(&v[0], v.size());
^
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:74: error: template argument 3 is invalid
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:74: error: template argument 4 is invalid
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:74: error: template argument 6 is invalid
C:/Program Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:24:27: error: template argument 1 is invalid
Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>> m(&v[0], v.size());
Then I installed Rstan from CRAN, version 2.19.2 but I got the same error as I reported above when trying to compile a model. What am I missing? Thanks.
I don’t think that I’m doing that. I’ll have a look at my environment variables right before and after trying to compile this model and then report back.
From this I don’t get the impression that the -mtune=native -march=native gets added at any point. I also don’t see it anywhere else - is there any other place I may be missing?
Nevermind, it seems there was a setting somewhere in the script that did overwrite LOCAL_CPPFLAGS; removing that seems to have fixed the problem. Apologies for missing that!