Error in compileCode(f, code, language = language, verbose = verbose) :

Hello! I am doing project on rstan and got the following error. Would you please give a help on it?
Thank you in advance!

Loading required package: ggplot2
Registered S3 methods overwritten by 'ggplot2':
  method         from 
  [.quosures     rlang
  c.quosures     rlang
  print.quosures rlang
Loading required package: StanHeaders
rstan (Version 2.18.2, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! cc1plus: error: unrecognized command line option "-std=gnu++14"
make: *** [/public/home/yabyibe/anaconda3/lib/R/etc/Makeconf:175: file14f6612510ee.o] Error 1
Calls: stan ... cxxfunctionplus -> <Anonymous> -> cxxfunction -> compileCode
In addition: Warning message:
In system(cmd, intern = !verbose) :
  running command '/public/home/yabyibe/anaconda3/lib/R/bin/R CMD SHLIB file14f6612510ee.cpp 2> file14f6612510ee.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection
Calls: stan -> stan_model -> cxxfunctionplus -> sink
Execution halted

Perhaps the above indicates that there might be something wrong in your Makevars file which on my Mac is in my home directory in the .R/ directory? Which compiler and OS are you using?

I am using Linux with gcc compiler

[yabyibe@login GM12878]$ which gcc
/usr/bin/gcc
[yabyibe@login GM12878]$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

That compiler is almost 8 years old and is based on an even older branch of GCC that does not know about the C++14 standard. You need GCC 5 or later, but if the server does not have them, you can download from

[yabyibe@comput18 ~]$ which  gcc
/public/home/software/opt/gcc/gcc-5.4.0/bin/gcc
[yabyibe@comput18 ~]$ gcc --version 
gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I used GCC 5.4.0 and got this error

   Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from /public/home/yabyibe/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /public/home/yabyibe/R/library/BH/include/boost/shared_ptr.hpp:17,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math/prim/mat.hpp:33,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math.hpp:4,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file158
Calls: stan ... cxxfunctionplus -> <Anonymous> -> cxxfunction -> compileCode
In addition: Warning message:
In system(cmd, intern = !verbose) :
  running command '/public/home/yabyibe/anaconda3/lib/R/bin/R CMD SHLIB file15846acd4061.cpp 2> file15846acd4061.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection
Calls: stan -> stan_model -> cxxfunctionplus -> sink
Execution halted

We need to see the output when you pass verbose = TRUE to stan or sampling, but doing it from Anaconda usually messes things up a little.

Same error displayed after I put verbose = TRUE

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from /public/home/yabyibe/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /public/home/yabyibe/R/library/BH/include/boost/shared_ptr.hpp:17,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math/prim/mat.hpp:33,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/stan/math.hpp:4,
                 from /public/home/yabyibe/anaconda3/lib/R/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file311
Calls: stan ... cxxfunctionplus -> <Anonymous> -> cxxfunction -> compileCode
Execution halted

Yes, but we need to see the line(s) that include the string error: (with the colon).