Interface Version: R version 3.6.0 (2019-04-26) – “Planting of a Tree”
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)
Compiler/Toolkit: g++
When I run “stan_model” to compile stan file, the following error comes.
I found similar topics online and tried various versions of “Makevars”, but still facing the error.
What can I do?
Thank you.
Error in compileCode(f, code, langu> age = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/BH/include/boost/random/detail/int_float_pair.hpp:26,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/BH/include/boost/random/exponential_distribution.hpp:27,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/BH/include/boost/random/gamma_distribution.hpp:25,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/mat.hpp:292,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/rev/mat.hpp:12,
from /home/changy/R/x86_64-redhat
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘/usr/lib64/R/bin/R CMD SHLIB file21352db2fbc.cpp 2> file21352db2fbc.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection
We need to see the error message when the verbose = TRUE argument is specified, but my guess is that your g++ is too old to implment the necessary parts of the C++14 standard.
However, after shutting off and turning on again, “g++ --version” goes back to
“g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)”, so I run the three lines again to raise to g++ 7.3.1.
In the Rserver interface corresponding to the CentOS (cloud computing at school), I debugged stan file via
It chopped off the relevant part, but it is almost surely trying to use the older g++. You may need to put CXX14 = g++-7 or something in the ~/.R/Makevars file.
“rstan” works well this June on R-server on the school cloud computing with CentOS 7.6. Now I use the same way and get the error. Maybe something changed in the CentOS?
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! /bin/sh: /opt/useful_stuff/g++: No such file or directory
make: *** [file5bb3a680c11.o] Error 127
First try g++ -v: this will print out (among other things) the version it’s finding by default. The path to that can be found with which g++.
If you have more than one version installed, it’s possible (if CentOS behaves like Ubuntu) that they are called g++-5, g++-7 and so on. If those are the names and you want g+±7, its path is which g++-7.
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from /usr/include/c++/4.8.2/type_traits:35:0,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/scal/meta/is_constant.hpp:4,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/arr/meta/is_constant_struct.hpp:4,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/mat/meta/is_constant_struct.hpp:4,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/mat.hpp:15,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/rev/mat.hpp:12,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math.hpp:4,
from /home/changy/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/src/stan
You are still using the g++ version 4.8.2. If you have installed a more recent version, put the path to that version in your Makevars, which you can find for example by doing which g++-7 if that’s what’s called on your system (an autocompletion on the Linux terminal might help you, so type g++ then press tab a couple of times to see what other executables start with that name).