Issues with boost preventing install of custom R package on department server (package depends on stan math library)

I have a created a custom R package that makes use of the autodiff capabilities of stan’s math library. I have been able to compile it and get it to work on my personal laptop, but I’ve been having trouble installing the package on my department server.

When I try to install the package, it fails with the following error message.

/home/nspencer/R/x86_64-redhat-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/arr/functor/integrate_1d.hpp:7:46: fatal error: boost/math/quadrature/exp_sinh.hpp: No such file or directory

#include <boost/math/quadrature/exp_sinh.hpp>

It seems as though StanHeaders is having trouble finding certain Boost files (like boost/math/quadrature/exp_sinh.hpp). I have been having trouble figuring out how to fix this problem. Has anyone encountered this before?

The installation instructions here provide information on how to specify the location of boost when compiling a simple program. Is there a similar approach I can take for the entire R package?


I think you just need a recent enough version of Boost (or the BH package that provides it) that has the quadrature stuff. I think it was introduced in Boost 1.66

Thank you for your response. I have these versions of Boost and BH. BH contains the quadrature files, but it seems to me (based on the error above) that they also have to be in the StanHeaders package, which they are not. I have the latest version of StanHeaders too.

Or at least StanHeaders needs to know where they are.

It works automatically if StanHeaders is specified on the LinkingTo: line of the DESCRIPTION file for your package.

Thanks. I was actually just able to get it to work by following all the instructions you gave in How to update a package that has StanHeaders and rstan in its LinkingTo