Compilation ERROR using brms pacakage

Hi,

To use brms package, I installed Rtools3.5, brms, rstan, and StanHeaders package in RStudio. Everything looks fine. However when I ran brms(), I got the following error:

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) : 
  file2c84291c6eb4.o:file2c84291c6eb4.cpp:(.data$_ZZN5boost4math6detail9bessel_y0IeNS0_8policies6policyINS3_13promote_floatILb0EEENS3_14promote_doubleILb0EEENS3_14default_policyES9_S9_S9_S9_S9_S9_S9_S9_S9_S9_EEEET_SB_RKT0_E2P1[_ZZN5boost4math6detail9bessel_y0IeNS0_8policies6policyINS3_13promote_floatILb0EEENS3_14promote_doubleILb0EEENS3_14default_policyES9_S9_S9_S9_S9_S9_S9_S9_S9_S9_EEEET_SB_RKT0_E2P1]+0x0): first defined hereC:/Users/changhe/Documents/R/win-library/3.6/rstan/lib/x64/libStanServices.a(stan_fit.o):stan_fit.cpp:(.rdata$_ZZN5boost4math6detail9bessel_y0IeNS0_8policies6policyINS3_13promote_floatILb0EEENS3_14promote_doubleILb0EEENS3_14default_policyES9_S9_S9_S9_S9_S9_S9_S9_S9_S9_EEEET_SB_RKT0_E2Q2[_ZZN5boost4math6detail9bessel_y0IeNS0_8policies6policyINS3_13promote_floatILb0EEENS3_14promote_doubleILb0EEENS3_14default_policyES9_S9_S9_S9_S9_S9_S9_S9_S9_S9_EEEET_SB_RKT0_E2Q2]+0x0): multiple definition of `long double boost::math::detail::bessel_y0<long double, boost::ma
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/Rtools/mingw_/bin/g++' not found

Thanks very much in advance!

My session information:
R version 3.6.3
os Windows 10 x64
RTools 3.5

1 Like

It might be that you don’t have properly setup your PATH variable. To avoid editing global path, you can set PATH in an .Renviron file stored in your home directory. This could look like:

PATH="C:\Rtools\usr\bin;C:\Rtools\mingw_64\bin;${PATH}"

(assuming Rtools is installed in C:\Rtools)

Hope that helps, if not, please ask for more help. I would additionally note that the CmdStanR package while still experimental is currently easier to install on most systems than Rstan and you can use brms with CmdStanR by setting options(brms.backend = "cmdstanr")

Also note that you can use triple backticks (```) to format code/program output neatly (I took the liberty to edit your post for you)