Stan installed but example code fails to run. Something about Rtools?

So this works

library(Rcpp)
cppFunction("double test() { return boost::math::constants::half_pi<double>(); }", 
            includes = c("// [[Rcpp::depends(BH)]]", 
                         "#include <boost/math/constants/constants.hpp>"), 
            verbose = TRUE)
test() # equals 0.5 * pi

?

Seems to work:

> library(Rcpp)
> 
> cppFunction("double test() { return boost::math::constants::half_pi<double>(); }", 
+ 
+             includes = c("// [[Rcpp::depends(BH)]]", 
+ 
+                          "#include <boost/math/constants/constants.hpp>"), 
+ 
+             verbose = TRUE)

Generated code for function definition: 
--------------------------------------------------------

#include <Rcpp.h>

using namespace Rcpp;

// [[Rcpp::depends(BH)]]
#include <boost/math/constants/constants.hpp>
// [[Rcpp::export]]
double test() { return boost::math::constants::half_pi<double>(); }

Generated extern "C" functions 
--------------------------------------------------------


#include <Rcpp.h>
// test
double test();
RcppExport SEXP sourceCpp_5_test() {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    rcpp_result_gen = Rcpp::wrap(test());
    return rcpp_result_gen;
END_RCPP
}

Generated R functions 
-------------------------------------------------------

`.sourceCpp_5_DLLInfo` <- dyn.load('/tmp/Rtmpc1ZywC/sourceCpp-x86_64-pc-linux-gnu-1.0.3/sourcecpp_a0911d32b272/sourceCpp_6.so')

test <- Rcpp:::sourceCppFunction(function() {}, FALSE, `.sourceCpp_5_DLLInfo`, 'sourceCpp_5_test')

rm(`.sourceCpp_5_DLLInfo`)

Building shared library
--------------------------------------------------------

DIR: /tmp/Rtmpc1ZywC/sourceCpp-x86_64-pc-linux-gnu-1.0.3/sourcecpp_a0911d32b272

/usr/local/lib/R/bin/R CMD SHLIB -o 'sourceCpp_6.so'  'filea091746b0c06.cpp'  
g++  -I"/usr/local/lib/R/include" -DNDEBUG   -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/"  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/"  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/unsupported"  -I"/usr/local/lib/R/library/BH/include" -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/"  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/"  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include" -DEIGEN_NO_DEBUG  -D_REENTRANT  -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp   -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I"/usr/local/lib/R/library/BH/include" -I"/tmp/Rtmpc1ZywC/sourceCpp-x86_64-pc-linux-gnu-1.0.3" -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I/usr/local/include   -fpic  -g -O2  -c filea091746b0c06.cpp -o filea091746b0c06.o
g++ -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o sourceCpp_6.so filea091746b0c06.o -L/usr/local/lib/R/lib -lR
> 
> test() # equals 0.5 * pi
[1] 1.570796
> library(Rcpp)
> 
> cppFunction("double test() { return boost::math::constants::half_pi<double>(); }", 
+ 
+             includes = c("// [[Rcpp::depends(BH)]]", 
+ 
+                          "#include <boost/math/constants/constants.hpp>"), 
+ 
+             verbose = TRUE)

Generated code for function definition: 
--------------------------------------------------------

#include <Rcpp.h>

using namespace Rcpp;

// [[Rcpp::depends(BH)]]
#include <boost/math/constants/constants.hpp>
// [[Rcpp::export]]
double test() { return boost::math::constants::half_pi<double>(); }

No rebuild required (use rebuild = TRUE to force a rebuild)

> 
> test() # equals 0.5 * pi
[1] 1.570796

PS I still have CXX14STD = -std=gnu++14 in Makevars. Should I change it back or leave it like this?

That is fine. Are you sure you are still getting

error: unable to find numeric literal operator \ufffd\ufffd\ufffdoperator""Q\ufffd\ufffd\ufffd

when you do something like

example(expose_stan_functions, package = "rstan", run.dontrun = TRUE)

after having put -fext-numeric-literals or -DBOOST_MATH_DISABLE_FLOAT128 into CXX14FLAGS in ~/.R/Makevars ?

You’re right, I don’t get that error any more. I get:

> example(expose_stan_functions, package = "rstan", run.dontrun = TRUE)

exps__> model_code <-
exps__+   '
exps__+   functions {
exps__+     real standard_normal_rng() {
exps__+       return normal_rng(0,1);
exps__+    }
exps__+   }
exps__+ '

exps__> expose_stan_functions(stanc(model_code = model_code))

exps__> standard_normal_rng()
[1] -0.9529876

exps__> PRNG <- get_rng(seed = 3)

exps__> o <- get_stream()

exps__> standard_normal_rng(PRNG, o)
[1] 0.882598

However, I still get and error when I run example(cxxfunction, package = "inline", run.dontrun = TRUE):

cxxfnc> # default plugin
cxxfnc> fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
cxxfnc+ 	return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
cxxfnc+ ' )

cxxfnc> fx( 2L, 5 )
[1] 10

cxxfnc> # Rcpp plugin
cxxfnc> if( require( Rcpp ) ){
cxxfnc+ 
cxxfnc+ 	fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
cxxfnc+ 		return wrap( as<int>(x) * as<double>(y) ) ;
cxxfnc+ 	', plugin = "Rcpp" )
cxxfnc+ 	fx( 2L, 5 )
cxxfnc+ 
cxxfnc+         ## equivalent shorter form using rcpp()
cxxfnc+ 	fx <- rcpp(signature(x = "integer", y = "numeric"),
cxxfnc+                    ' return wrap( as<int>(x) * as<double>(y) ) ; ')
cxxfnc+ 
cxxfnc+ }
Loading required package: Rcpp

Attaching package: \ufffd\ufffd\ufffdRcpp\ufffd\ufffd\ufffd

The following object is masked from \ufffd\ufffd\ufffdpackage:inline\ufffd\ufffd\ufffd:

    registerPlugin


cxxfnc> # RcppArmadillo plugin
cxxfnc> if( require( RcppArmadillo ) ){
cxxfnc+ 	
cxxfnc+ 	fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
cxxfnc+ 		int dim = as<int>( x ) ;
cxxfnc+ 		arma::mat z = as<double>(y) * arma::eye<arma::mat>( dim, dim ) ;
cxxfnc+ 		return wrap( arma::accu(z) ) ;
cxxfnc+ 	', plugin = "RcppArmadillo" )
cxxfnc+ 	fx( 2L, 5 )
cxxfnc+ 	
cxxfnc+ 	
cxxfnc+ }
Loading required package: RcppArmadillo
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called \ufffd\ufffd\ufffdRcppArmadillo\ufffd\ufffd\ufffd

And when I run example(stan_model, run.dontrun = TRUE), I get an output that goes through many screens and ends with:

 356 : SEXP file8326134fc3fb(  ){
 357 :  return Rcpp::wrap("16a540c6086086816528e4524def24d9");
 358 : }
 359 : 
 360 : 
Compilation argument:
 /usr/local/lib/R/bin/R CMD SHLIB file8326134fc3fb.cpp 2> file8326134fc3fb.cpp.err.txt 
g++ -std=gnu++14 -std=gnu++14 -I"/usr/local/lib/R/include" -DNDEBUG   -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/"  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/"  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/unsupported"  -I"/usr/local/lib/R/library/BH/include" -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/"  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/"  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include" -DEIGEN_NO_DEBUG  -D_REENTRANT  -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp  -I"/home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I/usr/local/include   -fpic  -O3 -Wno-unused-variable -Wno-unused-function -fPIC  -DBOOST_MATH_DISABLE_FLOAT128   -c file8326134fc3fb.cpp -o file8326134fc3fb.o
/usr/local/lib/R/etc/Makeconf:168: recipe for target 'file8326134fc3fb.o' failed
file8326134fc3fb.cpp:6:36: warning: ISO C++11 requires whitespace after the macro name
 #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
                                    ^
In file included from /usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/lib/R/library/BH/include/boost/shared_ptr.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/time_clock.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:13,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning: \ufffd\ufffd\ufffdtemplate<class> class std::auto_ptr\ufffd\ufffd\ufffd is deprecated [-Wdeprecated-declarations]
     explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
                                 ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /usr/include/c++/5/iomanip:43,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:5,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /usr/local/lib/R/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/time_clock.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:13,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: \ufffd\ufffd\ufffdtemplate<class> class std::auto_ptr\ufffd\ufffd\ufffd is deprecated [-Wdeprecated-declarations]
 template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
                                                                 ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /usr/include/c++/5/iomanip:43,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:5,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /usr/local/lib/R/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/time_clock.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:13,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:471:31: warning: \ufffd\ufffd\ufffdtemplate<class> class std::auto_ptr\ufffd\ufffd\ufffd is deprecated [-Wdeprecated-declarations]
     explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
                               ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /usr/include/c++/5/iomanip:43,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:5,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /usr/local/lib/R/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/time_clock.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:13,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:484:22: warning: \ufffd\ufffd\ufffdtemplate<class> class std::auto_ptr\ufffd\ufffd\ufffd is deprecated [-Wdeprecated-declarations]
     shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
                      ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /usr/include/c++/5/iomanip:43,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:5,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /usr/local/lib/R/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/time_clock.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:13,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:567:34: warning: \ufffd\ufffd\ufffdtemplate<class> class std::auto_ptr\ufffd\ufffd\ufffd is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> & r )
                                  ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /usr/include/c++/5/iomanip:43,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:5,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /usr/local/lib/R/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/time_clock.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:13,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:576:34: warning: \ufffd\ufffd\ufffdtemplate<class> class std::auto_ptr\ufffd\ufffd\ufffd is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> && r )
                                  ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /usr/include/c++/5/iomanip:43,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:5,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /usr/local/lib/R/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/time_clock.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:13,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp: In member function \ufffd\ufffd\ufffdboost::shared_ptr<T>& boost::shared_ptr<T>::operator=(std::auto_ptr<_Up>&&)\ufffd\ufffd\ufffd:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:578:38: warning: \ufffd\ufffd\ufffdtemplate<class> class std::auto_ptr\ufffd\ufffd\ufffd is deprecated [-Wdeprecated-declarations]
         this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
                                      ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /usr/include/c++/5/iomanip:43,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:5,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /usr/local/lib/R/library/BH/include/boost/random/detail/large_arithmetic.hpp:19:0,
                 from /usr/local/lib/R/library/BH/include/boost/random/detail/const_mod.hpp:23,
                 from /usr/local/lib/R/library/BH/include/boost/random/linear_congruential.hpp:30,
                 from /usr/local/lib/R/library/BH/include/boost/random/additive_combine.hpp:27,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:15,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/random/detail/integer_log2.hpp: In function \ufffd\ufffd\ufffdconstexpr int boost::random::detail::integer_log2(T)\ufffd\ufffd\ufffd:
/usr/local/lib/R/library/BH/include/boost/random/detail/integer_log2.hpp:74:9: error: \ufffd\ufffd\ufffdmax_pow2_less\ufffd\ufffd\ufffd is not a member of \ufffd\ufffd\ufffdboost::detail\ufffd\ufffd\ufffd
         ::boost::detail::max_pow2_less<
         ^
/usr/local/lib/R/library/BH/include/boost/random/detail/integer_log2.hpp:74:9: error: \ufffd\ufffd\ufffdmax_pow2_less\ufffd\ufffd\ufffd is not a member of \ufffd\ufffd\ufffdboost::detail\ufffd\ufffd\ufffd
/usr/local/lib/R/library/BH/include/boost/random/detail/integer_log2.hpp:76:9: error: wrong number of template arguments (2, should be 1)
         >::value
         ^
/usr/local/lib/R/library/BH/include/boost/random/detail/integer_log2.hpp:36:8: note: provided for \ufffd\ufffd\ufffdtemplate<int Shift> struct boost::random::detail::integer_log2_impl\ufffd\ufffd\ufffd
 struct integer_log2_impl
        ^
/usr/local/lib/R/library/BH/include/boost/random/detail/integer_log2.hpp:77:6: error: \ufffd\ufffd\ufffd::apply\ufffd\ufffd\ufffd has not been declared
     >::apply(t, 0);
      ^
/usr/local/lib/R/library/BH/include/boost/random/detail/integer_log2.hpp:77:6: note: suggested alternative:
In file included from /usr/local/lib/R/library/BH/include/boost/mpl/aux_/include_preprocessed.hpp:37:0,
                 from /usr/local/lib/R/library/BH/include/boost/mpl/apply_fwd.hpp:31,
                 from /usr/local/lib/R/library/BH/include/boost/mpl/apply.hpp:22,
                 from /usr/local/lib/R/library/BH/include/boost/mpl/aux_/iter_apply.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/mpl/aux_/find_if_pred.hpp:14,
                 from /usr/local/lib/R/library/BH/include/boost/mpl/find_if.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/mpl/find.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/mpl/aux_/contains_impl.hpp:20,
                 from /usr/local/lib/R/library/BH/include/boost/mpl/contains.hpp:20,
                 from /usr/local/lib/R/library/BH/include/boost/math/policies/policy.hpp:10,
                 from /usr/local/lib/R/library/BH/include/boost/math/special_functions/math_fwd.hpp:29,
                 from /usr/local/lib/R/library/BH/include/boost/math/special_functions/fpclassify.hpp:19,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:14,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/mpl/aux_/preprocessed/gcc/apply_fwd.hpp:18:8: note:   \ufffd\ufffd\ufffdboost::mpl::apply\ufffd\ufffd\ufffd
 struct apply;
        ^
In file included from /usr/local/lib/R/library/BH/include/boost/fusion/functional/invocation/detail/that_ptr.hpp:13:0,
                 from /usr/local/lib/R/library/BH/include/boost/fusion/functional/invocation/invoke.hpp:52,
                 from /usr/local/lib/R/library/BH/include/boost/fusion/functional/adapter/fused.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/fusion/functional/generation/make_fused.hpp:13,
                 from /usr/local/lib/R/library/BH/include/boost/fusion/include/make_fused.hpp:11,
                 from /usr/local/lib/R/library/BH/include/boost/numeric/odeint/util/resize.hpp:28,
                 from /usr/local/lib/R/library/BH/include/boost/numeric/odeint/util/state_wrapper.hpp:26,
                 from /usr/local/lib/R/library/BH/include/boost/numeric/odeint/util/ublas_wrapper.hpp:33,
                 from /usr/local/lib/R/library/BH/include/boost/numeric/odeint.hpp:25,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/arr/functor/integrate_ode_rk45.hpp:17,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/arr.hpp:46,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat.hpp:344,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:35,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/get_pointer.hpp: At global scope:
/usr/local/lib/R/library/BH/include/boost/get_pointer.hpp:48:40: warning: \ufffd\ufffd\ufffdtemplate<class> class std::auto_ptr\ufffd\ufffd\ufffd is deprecated [-Wdeprecated-declarations]
 template<class T> T * get_pointer(std::auto_ptr<T> const& p)
                                        ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /usr/include/c++/5/iomanip:43,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:5,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
make: *** [file8326134fc3fb.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: 
  2: // includes from the plugin
  3: // [[Rcpp::plugins(cpp14)]]
  4: 
  5: // user includes
  6: #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
  7: #include <rstan/rstaninc.hpp>
  8: // Code generated by Stan version 2.19.1

<snipping this part of output so I can fit more elsewhere>

356: SEXP file8326134fc3fb(  ){
357:  return Rcpp::wrap("16a540c6086086816528e4524def24d9");
358: }
359: 
360: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file8326134fc3fb.cpp:6:36: warning: ISO C++11 requires whitespace after the macro name
 #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
                                    ^
In file included from /usr/local/lib/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/lib/R/library/BH/include/boost/shared_ptr.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/time_clock.hpp:17,
                 from /usr/local/lib/R/library/BH/include/boost/date_time/posix_time/posix_time_types.hpp:10,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/stan_fit.hpp:13,
                 from /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
                 from file8326134fc3fb.cpp:7:
/usr/local/lib/R/library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning:

packageVersion("BH")?

1.66.0.1

install.packages("BH")

(Hi, sorry to disappear for a week! I hadn’t realized I had not actually submitted this comment… Thanks so much for sticking with me.)

OK, installed successfully and restarted R. But it says the version is still 1.66.0.1.

(And it still gives the same error on example(cxxfunction, package = "inline", run.dontrun = TRUE). I figured I’d check, though I know I’m probably checking the wrong things…)

Maybe

remove.packaes("BH")
install.packages("BH")
packageVersion("BH") # should be 1.72

OK, I got it to say 1.72 when I ask for packageVersion. It was a little confusing (for me, at least), so I include details here in case it’s relevant.

It turned out there were two different libraries in .libpaths(), and they were in reverse order in R vs RStudio. (Sigh.)

Rstudio has /home/mbernst/R/x86_64-pc-linux-gnu-library/3.5 as the default in .libpaths(); that’s where rstan is installed, and it also has the updated version of BH.

R itself has /usr/local/lib/R/library as the default, though I now understand how to change that in .libpaths() for a given R session. I think I might have some permissions issues in /usr/local/lib/R/library, which is why the installation was failing and kept giving me 1.66.

But in any case, I now understand how to make sure I’m in the correct library: the one where BH is version 1.72 and rstan is installed. However, example(cxxfunction, package = "inline", run.dontrun = TRUE) still gives the same error.

Thanks so much!

Which error is that again?

I just realized it’s only a warning message – and stan now actually seems to be running!!!
So I guess updating BH was the trick that fixed it.

THANK YOU SO MUCH!