Brms::brm_multiple() gives compilation error

Hi, I am running a Bayesian model on 100 imputed datasets using brms::brm_multiple, and I get following compilation error.

> fit <- brm_multiple(
+   formula,
+   data = imp_list,
+   family = bernoulli(),
+   prior = priors,
+   chains = 4,
+   iter = 2000,
+   warmup = 1000,
+   cores = 4,
+   seed = seed.value
+ )
Compiling the C++ model
Running /usr/lib/R/bin/R CMD SHLIB foo.c
using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
gcc -I"/usr/share/R/include" -DNDEBUG   -I"/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include/"  -I"/home/user/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/"  -I"/home/user/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/unsupported"  -I"/home/user/R/x86_64-pc-linux-gnu-library/4.4/BH/include" -I"/home/user/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/src/"  -I"/home/user/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/"  -I"/home/user/R/x86_64-pc-linux-gnu-library/4.4/RcppParallel/include/"  -I"/home/user/R/x86_64-pc-linux-gnu-library/4.4/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DUSE_STANC3 -DSTRICT_R_HEADERS  -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION  -D_HAS_AUTO_PTR_ETC=0  -include '/home/user/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1       -fpic  -g -O2 -ffile-prefix-map=/build/r-base-2y82rL/r-base-4.4.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c foo.c -o foo.o
In file included from /home/user/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/Core:19,
                 from /home/user/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/Dense:1,
                 from /home/user/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22,
                 from <command-line>:
/home/user/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/src/Core/util/Macros.h:679:10: fatal error: cmath: No such file or directory
  679 | #include <cmath>
      |          ^~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:195: foo.o] Error 1

  • Operating System: Linux Pop!OS 22.04
  • brms Version: (version 2.22.0)

Any advice how to get rid of the error?

Kr, Shiny

I have now sort of fixed it trying out different things:

  1. STEP
    sudo apt-get purge build-essential
    sudo apt-get install build-essential

  2. STEP
    sudo update-alternative --all

In STEP 2, I selected /usr/bin/clang++ as default and defaults for all other settings.

I also had installed cmdstan and included library(cmdstanr) in the R code, but the code worked with both versions (with and without cmdstan), so cmdstan was not needed.