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

**URL:** <https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390>\
**Category:** RStan\
**Tags:** rstan\
**Created:** [February 28, 2020, 7:04pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390 "2020-02-28T19:04:32Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [March 2, 2020, 3:43pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/21 "2020-03-02T15:43:50Z")

</div>

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

```

?

---

<div class="post-metadata">

**Author:** ![mirabernstein](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mirabernstein](https://discourse.mc-stan.org/u/mirabernstein)\
**Post date:** [March 2, 2020, 4:43pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/22 "2020-03-02T16:43:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [March 2, 2020, 4:47pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/23 "2020-03-02T16:47:24Z")

</div>

> [@mirabernstein](#):
>
> 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

```no-highlight
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 ?

---

<div class="post-metadata">

**Author:** ![mirabernstein](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mirabernstein](https://discourse.mc-stan.org/u/mirabernstein)\
**Post date:** [March 2, 2020, 7:58pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/24 "2020-03-02T19:58:49Z")

</div>

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:
```

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [March 2, 2020, 10:20pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/25 "2020-03-02T22:20:52Z")

</div>

`packageVersion("BH")`?

---

<div class="post-metadata">

**Author:** ![mirabernstein](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mirabernstein](https://discourse.mc-stan.org/u/mirabernstein)\
**Post date:** [March 2, 2020, 10:44pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/26 "2020-03-02T22:44:35Z")

</div>

1.66.0.1

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [March 2, 2020, 11:18pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/27 "2020-03-02T23:18:31Z")

</div>

`install.packages("BH")`

---

<div class="post-metadata">

**Author:** ![mirabernstein](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mirabernstein](https://discourse.mc-stan.org/u/mirabernstein)\
**Post date:** [March 9, 2020, 2:12pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/28 "2020-03-09T14:12:17Z")

</div>

(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…)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [March 9, 2020, 3:59pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/29 "2020-03-09T15:59:56Z")

</div>

Maybe

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

```

---

<div class="post-metadata">

**Author:** ![mirabernstein](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mirabernstein](https://discourse.mc-stan.org/u/mirabernstein)\
**Post date:** [March 9, 2020, 6:20pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/30 "2020-03-09T18:20:48Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [March 9, 2020, 6:29pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/31 "2020-03-09T18:29:03Z")

</div>

Which error is that again?

---

<div class="post-metadata">

**Author:** ![mirabernstein](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@mirabernstein](https://discourse.mc-stan.org/u/mirabernstein)\
**Post date:** [March 9, 2020, 6:56pm UTC](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390/32 "2020-03-09T18:56:19Z")

</div>

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!

[Previous page](https://discourse.mc-stan.org/t/stan-installed-but-example-code-fails-to-run-something-about-rtools/13390.md?page=1)
