Make: *** [lang__ast_def.o] Error 1

Problem:

I am trying to install RStan on several servers (below is one example), I always get the same error, that I cannot solve with the information in the many posts about compilation errors online

Operating System: Interface Version:

R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /stornext/System/data/apps/R/R-3.5.1/lib64/R/lib/libRblas.so
LAPACK: /stornext/System/data/apps/R/R-3.5.1/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8    
 [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8   
 [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] StanHeaders_2.18.0

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1    inline_0.3.15  yaml_2.1.19

Compiler/Toolkit:

g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)

Makevars:

cat ~/.R/Makevars
CXX_STD = CXX14
CXX14 = g++ # or clang++ if you have that
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION

Precautions:

run

install.packages("StanHeaders", repos = "https://cloud.r-project.org/", dependencies = TRUE)

before

install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)

Error:

/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:273:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1222:64: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
       add("student_t_rng", rng_return_type<double_type>(t, u, v), t, u, v);
                                                                ^
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:289:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&, const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t, const expr_type& u);
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:289:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1222:64: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
       add("student_t_rng", rng_return_type<double_type>(t, u, v), t, u, v);
                                                                ^
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:306:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&, const stan::lang::expr_type&, const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t,
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:306:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1222:64: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
       add("student_t_rng", rng_return_type<double_type>(t, u, v), t, u, v);
                                                                ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1320:18: error: ISO C++ forbids declaration of ‘t’ with no type [-fpermissive]
 for (const auto& t : all_vector_types) {
                  ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1320:22: error: range-based ‘for’ loops are not allowed in C++98 mode
 for (const auto& t : all_vector_types) {
                      ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1321:20: error: ISO C++ forbids declaration of ‘u’ with no type [-fpermissive]
   for (const auto& u : all_vector_types) {
                    ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1321:24: error: range-based ‘for’ loops are not allowed in C++98 mode
   for (const auto& u : all_vector_types) {
                        ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1322:57: error: no matching function for call to ‘stan::lang::function_signatures::rng_return_type(const int&, const int&)’
     add("uniform_rng", rng_return_type<double_type>(t, u), t, u);
                                                         ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1322:57: note: candidates are:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:273:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t);
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:273:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1322:57: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("uniform_rng", rng_return_type<double_type>(t, u), t, u);
                                                         ^
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:289:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&, const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t, const expr_type& u);
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:289:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1322:57: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("uniform_rng", rng_return_type<double_type>(t, u), t, u);
                                                         ^
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:306:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&, const stan::lang::expr_type&, const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t,
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:306:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1322:57: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("uniform_rng", rng_return_type<double_type>(t, u), t, u);
                                                         ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1339:18: error: ISO C++ forbids declaration of ‘t’ with no type [-fpermissive]
 for (const auto& t : all_vector_types) {
                  ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1339:22: error: range-based ‘for’ loops are not allowed in C++98 mode
 for (const auto& t : all_vector_types) {
                      ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1340:20: error: ISO C++ forbids declaration of ‘u’ with no type [-fpermissive]
   for (const auto& u : all_vector_types) {
                    ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1340:24: error: range-based ‘for’ loops are not allowed in C++98 mode
   for (const auto& u : all_vector_types) {
                        ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1341:59: error: no matching function for call to ‘stan::lang::function_signatures::rng_return_type(const int&, const int&)’
     add("von_mises_rng", rng_return_type<double_type>(t, u), t, u);
                                                           ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1341:59: note: candidates are:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:273:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t);
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:273:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1341:59: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("von_mises_rng", rng_return_type<double_type>(t, u), t, u);
                                                           ^
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:289:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&, const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t, const expr_type& u);
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:289:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1341:59: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("von_mises_rng", rng_return_type<double_type>(t, u), t, u);
                                                           ^
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:306:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&, const stan::lang::expr_type&, const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t,
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:306:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1341:59: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("von_mises_rng", rng_return_type<double_type>(t, u), t, u);
                                                           ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1364:18: error: ISO C++ forbids declaration of ‘t’ with no type [-fpermissive]
 for (const auto& t : all_vector_types) {
                  ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1364:22: error: range-based ‘for’ loops are not allowed in C++98 mode
 for (const auto& t : all_vector_types) {
                      ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1365:20: error: ISO C++ forbids declaration of ‘u’ with no type [-fpermissive]
   for (const auto& u : all_vector_types) {
                    ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1365:24: error: range-based ‘for’ loops are not allowed in C++98 mode
   for (const auto& u : all_vector_types) {
                        ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1366:57: error: no matching function for call to ‘stan::lang::function_signatures::rng_return_type(const int&, const int&)’
     add("weibull_rng", rng_return_type<double_type>(t, u), t, u);
                                                         ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1366:57: note: candidates are:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:273:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t);
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:273:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1366:57: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("weibull_rng", rng_return_type<double_type>(t, u), t, u);
                                                         ^
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:289:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&, const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t, const expr_type& u);
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:289:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1366:57: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("weibull_rng", rng_return_type<double_type>(t, u), t, u);
                                                         ^
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:65:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:7,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:306:17: note: template<class T> stan::lang::expr_type stan::lang::function_signatures::rng_return_type(const stan::lang::expr_type&, const stan::lang::expr_type&, const stan::lang::expr_type&)
       expr_type rng_return_type(const expr_type& t,
                 ^
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures.hpp:306:17: note:   template argument deduction/substitution failed:
In file included from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/sigs/function_signatures_def.hpp:486:0,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast_def.cpp:119,
                 from lang__ast_def.cpp:18:
/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/function_signatures.h:1366:57: note:   cannot convert ‘t’ (type ‘const int’) to type ‘const stan::lang::expr_type&’
     add("weibull_rng", rng_return_type<double_type>(t, u), t, u);
                                                         ^
make: *** [lang__ast_def.o] Error 1
ERROR: compilation failed for package ‘rstan’
* removing ‘/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/rstan’
Warning in install.packages :
  installation of package ‘rstan’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpzbyUtA/downloaded_packages’

Thanks for the support!

This compiler is not sufficient for C++14, although Stan is not actually using any C++14 syntax yet. Others have reported that you can probably get around errors like this by passing the -std=c++11 flag like

CXX14 = g++ -std=c++11

in ~/.R/Makevars but that is not going to be a long-term solution. Eventually and likely soon, you are going to need a compiler that supports C++14, which is g++-4.9 at a minimum or basically any clang++.

Thanks,

I managed to obtain g++ 7.3, and the error became .rodata.str1.8’ can not be used when making a shared object; recompile with -fPIC

In file included from /stornext/System/data/apps/gcc/gcc-7.3.0/include/c++/7.3.0/memory:80:0,
                 from /stornext/System/data/apps/R/R-3.5.1/lib64/R/library/BH/include/boost/move/algorithm.hpp:33,
                 from /stornext/System/data/apps/R/R-3.5.1/lib64/R/library/BH/include/boost/move/move.hpp:32,
                 from /stornext/System/data/apps/R/R-3.5.1/lib64/R/library/BH/include/boost/variant/detail/move.hpp:28,
                 from /stornext/System/data/apps/R/R-3.5.1/lib64/R/library/BH/include/boost/variant/recursive_wrapper.hpp:17,
                 from /stornext/System/data/apps/R/R-3.5.1/lib64/R/library/BH/include/boost/variant/detail/enable_recursive.hpp:34,
                 from /stornext/System/data/apps/R/R-3.5.1/lib64/R/library/BH/include/boost/variant/recursive_variant.hpp:17,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast/base_expr_type.hpp:4,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/ast.hpp:13,
                 from /stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/lang/compiler.hpp:5,
                 from stanc.cpp:22:
/stornext/System/data/apps/gcc/gcc-7.3.0/include/c++/7.3.0/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
g++ -shared -L/stornext/System/data/apps/R/R-3.5.1/lib64/R/lib -L/usr/local/lib64 -o rstan.so chains.o init.o lang__ast_def.o lang__grammars__bare_type_grammar_inst.o lang__grammars__expression07_grammar_inst.o lang__grammars__expression_grammar_inst.o lang__grammars__functions_grammar_inst.o lang__grammars__indexes_grammar_inst.o lang__grammars__program_grammar_inst.o lang__grammars__semantic_actions.o lang__grammars__statement_2_grammar_inst.o lang__grammars__statement_grammar_inst.o lang__grammars__term_grammar_inst.o lang__grammars__var_deccls_grammar_inst.o lang__grammars__whitespace_grammar_inst.o misc.o pointer-tools.o sparse_extractors.o stanc.o -L/stornext/System/data/apps/R/R-3.5.1/lib64/R/lib -lR
/usr/bin/ld: chains.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
chains.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [rstan.so] Error 1
ERROR: compilation failed for package ‘rstan’
* removing ‘/stornext/HPCScratch/home/mangiola.s/R/x86_64-pc-linux-gnu-library/3.5/rstan’

The Makevars

CXX_STD = CXX14
CXX14 = g++ #-7.3.0 # or clang++ if you have that
CXX14FLAGS = -O3 -fPIC -Wno-unused-variable -Wno-unused-function -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION

Did the job. Is unfortunate that RStan 2.18 is forced to be hard to install for C++14 adoption