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!
Hi @Rani Iām not sure I can help you. In my case there was a section in my R script that manually changed LOCAL_CPPFLAGS and added some lines that shouldnāt be there. Can you be more specific about what goes wrong on your computer?
installing source package ārstanā ā¦
** package ārstanā successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined
removing āC:/Users/ymb0814/Documents/R/R-3.6.2/library/rstanā
Warning in install.packages :
installation of package ārstanā had non-zero exit status
example(stan_model, package = ārstanā, run.dontrun = TRUE)
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.2, 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)
Do not specify ā-march=nativeā in āLOCAL_CPPFLAGSā or a Makevars file
stn_md> mod <- stan_model(model_code = stancode, verbose = TRUE)
TRANSLATING MODEL ā73fc79f8b1915e8208c736914c86d1a1ā FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ā73fc79f8b1915e8208c736914c86d1a1ā.
COMPILING THE C++ CODE FOR MODEL ā73fc79f8b1915e8208c736914c86d1a1ā NOW.
OS: x86_64, mingw32; rstan: 2.21.2; Rcpp: 1.0.5; inline: 0.3.17 Error in cleanup_makevar(old) : **
** argument āRMUā is missing, with no default
In addition: Warning messages:
1: package ārstanā was built under R version 3.6.3
2: package āStanHeadersā was built under R version 3.6.3
3: package āggplot2ā was built under R version 3.6.3
4: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
āC:/rtools40/usr/mingw_/bin/g++ā not found