CompileCode error after installation in Win 10

Dear list,
I am new to Stan and have recently installed “rstan” for the first time following the instruction provided here: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

The installation run with no issues, but I can’t get the “8school” example working, as I keep receiving the following error:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/matti/Documents/R/win-library/3.6/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from C:/Users/matti/Documents/R/win-library/3.6/BH/include/boost/random/detail/int_float_pair.hpp:26,
from C:/Users/matti/Documents/R/win-library/3.6/BH/include/boost/random/exponential_distribution.hpp:27,
from C:/Users/matti/Documents/R/win-library/3.6/BH/include/boost/random/gamma_distribution.hpp:25,
from C:/Users/matti/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from C:/Users/matti/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/mat.hpp:292,
from C:/Users/matti/Documents/R/win-library/3.6/StanHeaders/include/stan/math/rev/mat.hpp:12,
from C:/Users/matti/Documents/R/win-library/3.6/StanHeaders/include/stan/math.hpp:4,

I am working with RStudio (1.2.5001) in Windows 10:

  • R 3.6.1;
  • RTools 3.5;
  • rstan 2.19.2;
  • StanHeader 2.19.0;
  • rstantools 2.0.0.
  • I have installed RTools 3.5

Running

pkgbuild::has_build_tools(debug = TRUE)

returns TRUE, so my understanding is that the C++ toolchain is properly installed.

My .R/Makevars.win contains:

CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native

CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native

I have searched this and other forums for suggestions (downgrading rstan version, R, modifying Makevars.win) but none worked for me so far.

Your guidance and advise would be very much appreciated!

Best wishes,

Mattia

1 Like

Dear list folks,
I eventually solved the problem by simply deleting the Makevars.win file from the .R folder.

Sorry for rushing a question, I am a beginner and stan is a bit intimidating (apparently) even at the installation stage.
Best wishes,

M

3 Likes

Thanks for reporting back. It seems that on some systems the -march=native -mtune=native flags cause problems, so you were probably experiencing the same.

1 Like

Not a problem at all. Definitely feel free to ask when you need help. And if you have suggestions for how we can make Stan less intimidating those would also be very welcome if you feel like sharing. We’re always looking for ways to make things easier and it helps to know about user experiences.