Compilation error, maybe problem with Eigen and StanHeaders (Ubuntu)

#1

Hi, I was working with RStan and brms a few days ago, but for some reason am running into compilation errors now.

Poking around discouse I see ben asking people to run the following code:

stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}

mod <- stan_model(model_code = stancode, verbose = TRUE)

This outputs the following:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from /usr/local/lib/R/site-library/RcppEigen/include/Eigen/Core:388:0,
                 from /usr/local/lib/R/site-library/RcppEigen/include/Eigen/Dense:1,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core.hpp:14,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file20c026c4e5

When I try to compile my brms model I get what looks like a similar error:

Compiling the C++ model
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from /usr/local/lib/R/site-library/RcppEigen/include/Eigen/Core:380:0,
                 from /usr/local/lib/R/site-library/RcppEigen/include/Eigen/Dense:1,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core.hpp:14,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/stan/math.hpp:4,
                 from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file19aa1da2c4
In addition: Warning message:
running command '/usr/lib/R/bin/R CMD SHLIB file19aa1da2c48.cpp 2> file19aa1da2c48.cpp.err.txt' had status 1 

I am running Ubuntu 17.10, R 3.4.2, and Rstan 2.17.3.

My Makevars contains:

CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=g++

#2

You need to grep for the part of the message that includes the string error: and then tell us what that is.

1 Like
#3

Hi Ben, I’m sorry but I’m a bit confused: this is the entire message that is displayed and error: does not seem to appear.

Are errors sent to a separate file I’m not aware of?

#4

When you do

mod <- stan_model(model_code = stancode, verbose = TRUE)

there should be tons of output and you usually have to scroll up to get to the part about error:.

#5

Hi, the line that includes error: is:

error: ‘enable_both’ is not a member of ‘boost::exception_detail’
     throw exception_detail::enable_both( e );
#6

OK, if your

packageVersion("BH")

is not 1.69, then try upgrading to the latest version of the BH package.

#7

My BH package is version 1.69.0.1

#8

This seems to be coming from
https://www.boost.org/doc/libs/1_69_0/boost/throw_exception.hpp
Do you have anything about -DBOOST_EXCEPTION_DISABLE in your Makevars file?

#9

No, and I tried resetting the Makevars as per the Linux Rstan installation guide. My Makevars is:

CXX14FLAGS=-03 -march=native -mtune=native -fPIC
CXX14=g++

#10

It is possible that there are incompatibilities between RStan 2.17.3 and some combination of StanHeaders 2.18.x and Boost 1.69. I would upgrade the RStan.

#11

This worked! Thanks Ben, I’m not sure what changed to make the incompatibility show up, maybe updating of a different package plus dependencies…