Iβm getting closer. I followed the example and have stripped everything back to its bare minimum. I am trying to run the following example:
require(rstan)
model_code <-
'
functions {
real standard_normal_rng() {
return normal_rng(0,1);
}
}
'
stan_model(model_code = model_code, allow_undefined = TRUE, includes = paste0('\n#include "', file.path(getwd(), 'myqgamma.hpp'), '"\n'))
where myqgamma.hpp contains the following:
#include <boost/math/distributions/gamma.hpp>
double myqgamma(double p, double shape, double scale) {
boost::math::gamma_distribution<> dist(shape, scale);
return quantile(dist, p);
}
I get the following error:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! file1e4df46976a433.cpp:6:9: warning: ISO C++11 requires whitespace after the macro name
6 | #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/jhstagge/R/x86_64-pc-linux-gnu-library/4.0/RcppEigen/include/Eigen/Core:383,
from /home/jhstagge/R/x86_64-pc-linux-gnu-library/4.0/RcppEigen/include/Eigen/Dense:1,
from /home/jhstagge/R/x86_64-pc-linux-gnu-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13,
from <command-line>:
/home/jhstagge/R/x86_64-pc-linux-gnu-library/4.0/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument β__m128β [-Wignored-attributes]
60 | template<> struct is_arithmetic<__m128> { enum { value = true }; };
| ^
/home/jhstagge/R/x86_6
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command '/usr/lib64/R/bin/R CMD SHLIB file1e4df46976a433.cpp 2> file1e4df46976a433.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection
I have tracked down this error message to previous posts, for example. I updated rstan, BH, and StanHeaders to make sure I am using the most current versions.
When I remove the includes command, the model compiles properly. So, I donβt think it is an issue with the compiler/rstan, I think it must be something in myqgamma.hpp file.
I feel like Iβm almost there. Any thoughts?