Compilation error when linking Stan to Eigen

I’ve recently downloaded Stan from github and I’m trying to use the automatic differentiation package. However, on including the header <stan/math.hpp>, I get the following error:

/Users/hannesvdc/math/stan/math/rev/fun/dot_product.hpp:43:16: error: no member
  named 'val' in 'Eigen::Map<Eigen::Matrix<stan::math::vari *, -1, 1, 0, -1,
  1>, 0, Eigen::Stride<0, 0> >'
return vd1.val().dot(vd2.val());

I have the latest version of Eigen (3.3.7) installed on my mac (OSX Catalina 10.15.2). When I look at the eigen code, the object Eigen::Map does indeed not possess a member ‘val’.

Has anyone had this issue before?

Regards,

Hannes Vandecasteele

You need to have a StanHeaders that is up to date. Do

source("https://raw.githubusercontent.com/stan-dev/rstan/develop/StanHeaders/install-github.R")
install_StanHeaders(math_branch = "StanHeaders_2.21",
                               library_branch = "StanHeaders_2.21")