Error installing R stan on Centos7 Linux server: Error: C++14 standard requested but CXX14 is not defined
I am trying to install rstan on a linux server. I run the usual command
install.packages("rstan")
And get the following output:
Installing package into ‘/home/user/R/x86_64-pc-linux-gnu-library/4.2’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/src/contrib/rstan_2.21.5.tar.gz' Content type 'application/x-gzip' length 1189130 bytes (1.1 MB)
================================================== downloaded 1.1 MB
* installing source package ‘rstan’ ... ** package ‘rstan’ successfully unpacked and MD5 sums checked ** using staged installation ** libs Error: C++14 standard requested but CXX14 is not defined * removing ‘/home/tolani/R/x86_64-pc-linux-gnu-library/4.2/rstan’ Warning in install.packages : installation of package ‘rstan’ had non-zero exit status
The downloaded source packages are in ‘/tmp/RtmpVMgIkm/downloaded_packages’
I am running this on R version 4.2.0 on CentOS7. Any help with this would be greatly appreciated! Thank you.
I do not really if you have following the office to Configuring C++ Toolchain

If you have do that try to downgrade your R to lower version like 4.0.2 or someone find 4.0.5 is work,recently, i also found 4.2.0 may be not fit Rstan~ hope it work
@sir-chester I don't know specifically what's going on in your case, but I've bumped into issues installing Stan on an aged Linux server and the problems there were due to the version of gcc being out of date. I was able to make progress by installing a later version of gcc. However, I was hesitant to install that later version as the default since there could be a lot of dependencies on the older version and I didn't want to even think about updating the whole system.
Specifically, I was working on a Ubuntu 14.04 system and the installed gcc version was 4.something. I installed gcc 9 and when I launch R, I supply environment variables to tell Stan to use gcc 9, like this:
$ CC=gcc-9 CXX=g++-9 R
I guess the executables which got installed are named gcc-9 and g++-9 and not gcc and g++; now that I think of it, that's kind of surprising.
I don't know what the minimal version of gcc might be. I think I tried to install later versions of gcc, and gcc 10 and later failed to install, so gcc 9 is just the latest version that was installed successfully.
This is resolved by adding a line to your Makevars with:
CXX14 = g++-{your gcc version here}