Stan 2.16.2 install error

Having trouble updating rstan to the latest version on Linux. These are the errors I get:

/R/x86_64-redhat-linux-gnu-library/3.3/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40: error: ISO C++ forbids initialization of member ‘has_var_’
/R/x86_64-redhat-linux-gnu-library/3.3/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40: error: making ‘has_var_’ static
/R/x86_64-redhat-linux-gnu-library/3.3/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40: error: ISO C++ forbids in-class initialization of non-const static member ‘has_var_’
make: *** [lang__ast_def.o] Error 1

Any thoughts on what is going wrong?


You need to add -std=c++11 to CXXFLAGS in your ~/.R/Makevars file

Thanks for your feedback! Unfortunately I don’t have much of a computer science background, so I can’t really understand what that sentence means.

It isn’t a computer science thing; it is just operating an account on a Linux server. Once you log into a shell, execute

echo "CXXFLAGS += -std=c++11" >> ~/.R/Makevars

and then it should be fine.

Ok thanks so much for you patience! Sorry I also don’t have very much experience with Linux either :-/

I don’t seem to have the hidden file .R in my home directory. How should I proceed?

Just run this command without the quotes: “mkdir ~/.R”

Ok so I tried doing this and I get the following error:

cc1plus: error: unrecognized command line option "-std=c++11"

My ~/.R/Makevars file looks like this:

CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function
CXXFLAGS += -std=c++11

What compiler and version are you using?

Hi! I’m facing exactly the same issue. I’m compiling with gcc with the following version:

gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)

Thank you!

If you are on Red Hat Enterprise 6 (and judging from that GCC version, that seems to be the case), I’d recommend getting (or asking the sysadmin to get) the free Red Hat Developer Toolset, which has a more up-to-date developer toolchain.

Yeah when I updated to Red Hat 7, it fixed the install problem.

I am not sure whether a stock RHEL7 is going to be adequate going forward. For Stan 2.18.x, the minimum requirement is going to be g++-4.9 or a more recent version of clang++. You can get those for RHEL7 but I don’t know if they come with RHEL7.

Not to sound like a shill for RHEL, but you can get the Red Hat Developer Toolset for RHEL7 as well. It should have proper support for C++11.

I’m now using gcc 6.3.1, but installing still fails with the error

 static type make(typename call_traits<A>::param_type... a)

/usr/lib64/R/etc/Makeconf:166: recipe for target ‘lang__grammars__expression_grammar_inst.o’ failed
make: *** [lang__grammars__expression_grammar_inst.o] Error 1

Can confirm that this works. Thanks for the help.