Error while loading the package

I have followed the instruction of installing rstan for Rstudio in Windows 10 and here is what I got while loading rstan:

> remove.packages("rstan")
Removing package from ‘C:/Users/Samira/Anaconda3/envs/rstudio/lib/R/library’
(as ‘lib’ is unspecified)
> if (file.exists(".RData")) file.remove(".RData")

Restarting R session...

> install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)
also installing the dependencies ‘crosstalk’, ‘zoo’, ‘igraph’, ‘colourpicker’, ‘DT’, ‘dygraphs’, ‘shinyjs’, ‘shinythemes’, ‘threejs’, ‘xts’, ‘ggridges’, ‘RUnit’, ‘shinystan’, ‘bayesplot’, ‘rstantools’

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/crosstalk_1.1.0.1.zip'
Content type 'application/zip' length 778657 bytes (760 KB)
downloaded 760 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/zoo_1.8-8.zip'
Content type 'application/zip' length 1096244 bytes (1.0 MB)
downloaded 1.0 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/igraph_1.2.5.zip'
Content type 'application/zip' length 9172062 bytes (8.7 MB)
downloaded 8.7 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/colourpicker_1.0.zip'
Content type 'application/zip' length 1955137 bytes (1.9 MB)
downloaded 1.9 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/DT_0.14.zip'
Content type 'application/zip' length 1744175 bytes (1.7 MB)
downloaded 1.7 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/dygraphs_1.1.1.6.zip'
Content type 'application/zip' length 443100 bytes (432 KB)
downloaded 432 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/shinyjs_1.1.zip'
Content type 'application/zip' length 1040754 bytes (1016 KB)
downloaded 1016 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/shinythemes_1.1.2.zip'
Content type 'application/zip' length 990214 bytes (967 KB)
downloaded 967 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/threejs_0.3.3.zip'
Content type 'application/zip' length 948742 bytes (926 KB)
downloaded 926 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/xts_0.12-0.zip'
Content type 'application/zip' length 966518 bytes (943 KB)
downloaded 943 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/ggridges_0.5.2.zip'
Content type 'application/zip' length 2312288 bytes (2.2 MB)
downloaded 2.2 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/RUnit_0.4.32.zip'
Content type 'application/zip' length 297586 bytes (290 KB)
downloaded 290 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/shinystan_2.5.0.zip'
Content type 'application/zip' length 1287772 bytes (1.2 MB)
downloaded 1.2 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/bayesplot_1.7.2.zip'
Content type 'application/zip' length 4917407 bytes (4.7 MB)
downloaded 4.7 MB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/rstantools_2.1.1.zip'
Content type 'application/zip' length 160769 bytes (157 KB)
downloaded 157 KB

trying URL 'https://cloud.r-project.org/bin/windows/contrib/3.6/rstan_2.21.1.zip'
Content type 'application/zip' length 5863918 bytes (5.6 MB)
downloaded 5.6 MB

package ‘crosstalk’ successfully unpacked and MD5 sums checked
package ‘zoo’ successfully unpacked and MD5 sums checked
package ‘igraph’ successfully unpacked and MD5 sums checked
package ‘colourpicker’ successfully unpacked and MD5 sums checked
package ‘DT’ successfully unpacked and MD5 sums checked
package ‘dygraphs’ successfully unpacked and MD5 sums checked
package ‘shinyjs’ successfully unpacked and MD5 sums checked
package ‘shinythemes’ successfully unpacked and MD5 sums checked
package ‘threejs’ successfully unpacked and MD5 sums checked
package ‘xts’ successfully unpacked and MD5 sums checked
package ‘ggridges’ successfully unpacked and MD5 sums checked
package ‘RUnit’ successfully unpacked and MD5 sums checked
package ‘shinystan’ successfully unpacked and MD5 sums checked
package ‘bayesplot’ successfully unpacked and MD5 sums checked
package ‘rstantools’ successfully unpacked and MD5 sums checked
package ‘rstan’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\Samira\AppData\Local\Temp\RtmpI5zVia\downloaded_packages
> pkgbuild::has_build_tools(debug = TRUE)
trying URL 'https://cran.rstudio.com/bin/windows/Rtools/Rtools35.exe'
Content type 'application/x-msdownload' length 108622512 bytes (103.6 MB)
downloaded 103.6 MB

[1] FALSE
> dotR <- file.path(Sys.getenv("HOME"), ".R")
> if (!file.exists(dotR)) dir.create(dotR)
> M <- file.path(dotR, ifelse(.Platform$OS.type == "windows", "Makevars.win", "Makevars"))
> if (!file.exists(M)) file.create(M)
[1] TRUE
library("rstan") # observe startup messages
Error: package or namespace load failed for ‘rstan’ in .doLoadActions(where, attach):
 error in load action .__A__.1 for package rstan: Rcpp::loadModule(module = "class_model_base", what = TRUE, env = ns, : Unable to load module "class_model_base": cannot allocate vector of size 11881.9 Gb
In addition: Warning message:
package ‘rstan’ was built under R version 3.6.3 

Please let me know what is the solution of this problem?
Operating System: Windows 10
R version 3.6.1 (2019-07-05) – “Action of the Toes”
Platform: x86_64-w64-mingw32/x64 (64-bit)

I changed my Makevars.win file to be like this:
CXX14FLAGS=-O3 -mtune=native
CXX11FLAGS=-O3 -march=corei7 -mtune=corei7
Then This is what I get again:
Restarting R session…

> remove.packages("rstan")
Removing package from ‘C:/Users/Samira/Anaconda3/envs/rstudio/lib/R/library’
(as ‘lib’ is unspecified)
Error in remove.packages : there is no package called ‘rstan’
> if (file.exists(".RData")) file.remove(".RData")
> #install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE) pkgbuild::has_build_tools(debug = TRUE)
> 
> install.packages(
+   "https://win-builder.r-project.org/FY6dGt9toIR7/StanHeaders_2.21.0-6.zip",
+   repos = NULL, type = "win.binary")
trying URL 'https://win-builder.r-project.org/FY6dGt9toIR7/StanHeaders_2.21.0-6.zip'
Content type 'application/x-zip-compressed' length 2358086 bytes (2.2 MB)
downloaded 2.2 MB

package ‘StanHeaders’ successfully unpacked and MD5 sums checked
> install.packages(
+   "https://win-builder.r-project.org/axT8tC59Z2B8/rstan_2.21.2.zip",
+   repos = NULL, type = "win.binary")
trying URL 'https://win-builder.r-project.org/axT8tC59Z2B8/rstan_2.21.2.zip'
Content type 'application/x-zip-compressed' length 5877062 bytes (5.6 MB)
downloaded 5.6 MB

package ‘rstan’ successfully unpacked and MD5 sums checked
> library("rstan") # observe startup messages
Loading required package: StanHeaders
Loading required package: ggplot2
Error: package or namespace load failed for ‘rstan’ in .doLoadActions(where, attach):
 error in load action .__A__.1 for package rstan: Rcpp::loadModule(module = "class_model_base", what = TRUE, env = ns, : Unable to load module "class_model_base": cannot allocate vector of size 9348.7 Gb
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

It is possible the 3.6.3 vs. 3.6.1 thing makes a difference, although I would have doubted it. Maybe try installing Rcpp from source before loading rstan?

I installed R version 3.4 and Rstudio version 1.2.5 and Rtools 3.4 and tried the instruction again, but this time I am getting this error:
Restarting R session…

install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)
Installing package into ‘D:/My Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)

There is a binary version available but the source version is later:
binary source needs_compilation
rstan 2.18.2 2.21.2 TRUE

Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package ‘rstan’

trying URL ‘https://cloud.r-project.org/src/contrib/rstan_2.21.2.tar.gz
Content type ‘application/x-gzip’ length 1152008 bytes (1.1 MB)
downloaded 1.1 MB

  • installing source package ‘rstan’ …
    ** package ‘rstan’ successfully unpacked and MD5 sums checked
    ** libs

*** arch - i386
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c Module.cpp -o Module.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c chains.cpp -o chains.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c init.cpp -o init.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c misc.cpp -o misc.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c pointer-tools.cpp -o pointer-tools.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c sparse_extractors.cpp -o sparse_extractors.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan_fit_base.cpp -o stan_fit_base.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan_fit_rccp.cpp -o stan_fit_rccp.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stanc.cpp -o stanc.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/ast_def.cpp -o stan/lang/ast_def.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/bare_type_grammar_inst.cpp -o stan/lang/grammars/bare_type_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/block_var_decls_grammar_inst.cpp -o stan/lang/grammars/block_var_decls_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/expression07_grammar_inst.cpp -o stan/lang/grammars/expression07_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/expression_grammar_inst.cpp -o stan/lang/grammars/expression_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/functions_grammar_inst.cpp -o stan/lang/grammars/functions_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/indexes_grammar_inst.cpp -o stan/lang/grammars/indexes_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/local_var_decls_grammar_inst.cpp -o stan/lang/grammars/local_var_decls_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/program_grammar_inst.cpp -o stan/lang/grammars/program_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/semantic_actions_def.cpp -o stan/lang/grammars/semantic_actions_def.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/statement_2_grammar_inst.cpp -o stan/lang/grammars/statement_2_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/statement_grammar_inst.cpp -o stan/lang/grammars/statement_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/term_grammar_inst.cpp -o stan/lang/grammars/term_grammar_inst.o
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan/lang/grammars/whitespace_grammar_inst.cpp -o stan/lang/grammars/whitespace_grammar_inst.o
C:\Rtools\mingw_32\bin\nm.exe: Module.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: chains.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: init.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: misc.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: pointer-tools.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: sparse_extractors.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan_fit_base.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan_fit_rccp.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stanc.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/ast_def.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/bare_type_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/block_var_decls_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/expression07_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/expression_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/functions_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/indexes_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/local_var_decls_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/program_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/semantic_actions_def.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/statement_2_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/statement_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/term_grammar_inst.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: stan/lang/grammars/whitespace_grammar_inst.o: File format not recognized
g++ -std=c++1y -shared -s -static-libgcc -o rstan.dll tmp.def Module.o chains.o init.o misc.o pointer-tools.o sparse_extractors.o stan_fit_base.o stan_fit_rccp.o stanc.o stan/lang/ast_def.o stan/lang/grammars/bare_type_grammar_inst.o stan/lang/grammars/block_var_decls_grammar_inst.o stan/lang/grammars/expression07_grammar_inst.o stan/lang/grammars/expression_grammar_inst.o stan/lang/grammars/functions_grammar_inst.o stan/lang/grammars/indexes_grammar_inst.o stan/lang/grammars/local_var_decls_grammar_inst.o stan/lang/grammars/program_grammar_inst.o stan/lang/grammars/semantic_actions_def.o stan/lang/grammars/statement_2_grammar_inst.o stan/lang/grammars/statement_grammar_inst.o stan/lang/grammars/term_grammar_inst.o stan/lang/grammars/whitespace_grammar_inst.o -LD:/My Documents/R/win-library/3.4/RcppParallel/lib/i386 -ltbb -ltbbmalloc -LC:/PROGRA~1/R/R-34~1.4/bin/i386 -lR
g++.exe: error: Documents/R/win-library/3.4/RcppParallel/lib/i386: No such file or directory
g++ -std=c++1y -I"C:/PROGRA~1/R/R-34~1.4/include" -DNDEBUG -I"…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I"D:/My Documents/R/win-library/3.4/Rcpp/include" -I"D:/My Documents/R/win-library/3.4/RcppEigen/include" -I"D:/My Documents/R/win-library/3.4/BH/include" -I"D:/My Documents/R/win-library/3.4/StanHeaders/include" -I"D:/My Documents/R/win-library/3.4/RcppParallel/include" -DRCPP_PARALLEL_USE_TBB=1 -O3 -march=native -mtune=native -c stan_fit.cpp -o stan_fit.o
c:/Rtools/mingw_32/bin/ar -rs …/inst/lib//i386/libStanServices.a stan_fit.o stan_fit_base.o
C:\Rtools\mingw_32\bin\ar.exe: creating …/inst/lib//i386/libStanServices.a
no DLL was created
ERROR: compilation failed for package ‘rstan’

  • removing ‘D:/My Documents/R/win-library/3.4/rstan’
    In R CMD INSTALL
    Warning in install.packages :
    running command ‘“C:/PROGRA~1/R/R-34~1.4/bin/x64/R” CMD INSTALL -l “D:\My Documents\R\win-library\3.4” C:\Users\Samira\AppData\Local\Temp\Rtmpe4EaGg/downloaded_packages/rstan_2.21.2.tar.gz’ had status 1
    Warning in install.packages :
    installation of package ‘rstan’ had non-zero exit status

What’s in your ~/.R/Makevars and / or ~./R/Makevars.win files? You need to take the -march=native stuff out of the compilation flags. Alternatively, you can install the binary packages from

I removed it and this is what I am getting:
file.edit(“~/.R/Makevars”)

install.packages(

Those binaries might not work on versions of R < 3.6. You can try to install from source.

1 Like