Compilation Error

Hello,

I have been using RStan for a few months, and despite successfully installing it, today I received the below error message for the first time:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/ … /R/win-library/3.5/BH/include/boost/config.hpp:39:0,
from C:/Users/ … /R/win-library/3.5/BH/include/boost/math/tools/config.hpp:13,
from C:/Users/ … /R/win-library/3.5/StanHeaders/include/stan/math/rev/core/var.hpp:7,
from C:/Users/ … /R/win-library/3.5/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
from C:/Users/ … /R/win-library/3.5/StanHeaders/include/stan/math/rev/core.hpp:12,
from C:/Users/ … /R/win-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:4,
from C:/Users/ … /R/win-library/3.5/StanHeaders/include/stan/math.hpp:4,
from C:/Users/ … /R/win-library/3.5/StanHeaders/include/src/stan
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-35~1.1/bin/x64/R CMD SHLIB file31e85fc76ef5.cpp 2> file31e85fc76ef5.cpp.err.txt’ had status 1

This seems similar to error messages I’ve seen associated with installation errors, so I have re-installed RTools (version 3.4).

Note that…

fx <- inline::cxxfunction( signature(x = “integer”, y = “numeric” ) , ’
return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
’ )
fx( 2L, 5 ) # should be 10

…does return 10

Operating System: Windows 10
R version: 3.5.1

Other session info:

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] extrafont_0.17 shinystan_2.5.0 shiny_1.1.0 rstan_2.17.3 StanHeaders_2.17.2 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.6 purrr_0.2.5
[10] readr_1.1.1 tidyr_0.8.1 tibble_1.4.2 ggplot2_3.0.0 tidyverse_1.2.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 lubridate_1.7.4 lattice_0.20-35 gtools_3.8.1 zoo_1.8-4 assertthat_0.2.0 digest_0.6.17 mime_0.5 R6_2.2.2
[10] cellranger_1.1.0 plyr_1.8.4 ggridges_0.5.0 backports_1.1.2 stats4_3.5.1 colourpicker_1.0 httr_1.3.1 pillar_1.3.0 rlang_0.2.2
[19] lazyeval_0.2.1 readxl_1.1.0 miniUI_0.1.1.1 rstudioapi_0.7 extrafontdb_1.0 DT_0.4 shinythemes_1.1.1 shinyjs_1.0 htmlwidgets_1.2
[28] igraph_1.2.2 munsell_0.5.0 broom_0.5.0 compiler_3.5.1 httpuv_1.4.5 modelr_0.1.2 pkgconfig_2.0.2 base64enc_0.1-3 htmltools_0.3.6
[37] tidyselect_0.2.4 gridExtra_2.3 threejs_0.3.1 crayon_1.3.4 withr_2.1.2 later_0.7.5 grid_3.5.1 Rttf2pt1_1.3.7 nlme_3.1-137
[46] jsonlite_1.5 xtable_1.8-3 gtable_0.2.0 magrittr_1.5 scales_1.0.0 cli_1.0.1 stringi_1.2.4 reshape2_1.4.3 promises_1.0.1
[55] bindrcpp_0.2.2 xml2_1.2.0 dygraphs_1.1.1.6 xts_0.11-1 tools_3.5.1 glue_1.3.0 markdown_0.8 hms_0.4.2 crosstalk_1.0.0
[64] parallel_3.5.1 rsconnect_0.8.8 yaml_2.2.0 inline_0.3.15 colorspace_1.3-2 bayesplot_1.6.0 rvest_0.3.2 bindr_0.1.1 haven_1.1.2

Please let me know if any other details would be helpful. Thanks!

Stan program

Hi,

I’m getting this error with Stan programs that have previously run for me, including the 8 schools example from the ‘getting started’ github page.

Below is exactly as I have it in RStudio:
test.stan

// saved as 8schools.stan
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
}
parameters {
real mu;
real<lower=0> tau;
real eta[J];
}
transformed parameters {
real theta[J];
for (j in 1:J)
theta[j] = mu + tau * eta[j];
}
model {
target += normal_lpdf(eta | 0, 1);
target += normal_lpdf(y | theta, sigma);
}

test.R

library(rstan)

schools_dat <- list(J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18))

fit <- stan(file = ‘test.stan’, data = schools_dat,
iter = 1000, chains = 4)

Okay, it is probably a configuration problem then. What is the first part of the error message?

Sorry, I should have included this earlier…

In file included from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/BH/include/boost/config.hpp:39:0,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/BH/include/boost/math/tools/config.hpp:13,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core/var.hpp:7,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core.hpp:12,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:4,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/stan/math.hpp:4,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file41c42dc21d50.cpp:8:
C:/Users/domen/OneDrive/Documents/R/win-library/3.5/BH/include/boost/config/compiler/gcc.hpp:186:0: warning: “BOOST_NO_CXX11_RVALUE_REFERENCES” redefined

define BOOST_NO_CXX11_RVALUE_REFERENCES

^
:0:0: note: this is the location of the previous definition
In file included from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/src/stan/optimization/lbfgs_update.hpp:6:0,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/src/stan/optimization/bfgs.hpp:9,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/StanHeaders/include/src/stan/services/optimize/bfgs.hpp:11,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/rstan/include/rstan/stan_fit.hpp:36,
from C:/Users/domen/OneDrive/Documents/R/win-library/3.5/rstan/include/rstan/rstaninc.hpp:3,
from file41c42dc21d50.cpp:478:
C:/Users/domen/OneDrive/Documents/R/win-library/3.5/BH/include/boost/circular_buffer.hpp:53:43: fatal error: boost/circular_buffer/debug.hpp: No such file or directory
#include <boost/circular_buffer/debug.hpp>
^
compilation terminated.
make: *** [file41c42dc21d50.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

The above is followed by a few hundred lines of 'Program source: ’
and then by the text in my first message, above.

Do you have an up-to-date BH package?

Hi Ben,
I’ve just re-installed the BH package and my models are running again.
Thanks a lot for your help, and for getting back to me so quickly!

Sorry for commenting on an already resolved thread … but, I am getting the exact same error, and I have also updated my “BH” package, it didn’t solve the issue.

  Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from 
  C:/Users/jd033/Documents/R/win-library/3.5/BH/include/boost/config.hpp:39:0,
             from C:/Users/jd033/Documents/R/win-library/3.5/BH/include/boost/math/tools/config.hpp:13,
             from C:/Users/jd033/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core/var.hpp:7,
             from C:/Users/jd033/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
             from C:/Users/jd033/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core.hpp:12,
             from C:/Users/jd033/Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:4,
             from C:/Users/jd033/Documents/R/win-library/3.5/StanHeaders/include/stan/math.hpp:4,
             from C:/Users/jd033/Documents/R/win-library/3.5/StanHeaders/include/src/stan/model/model_header.hpp:4,
             from file1f0443101b35.cpp:8:
In addition: Warning messages:
1: In stan_model(model_code = stan.hsplus.code, model_name = "hs+ cauchy") :
  StanHeaders version is ahead of rstan version; update to latest rstan
2: In system(cmd, intern = !verbose) :
  running command 'C:/PROGRA~1/R/R-3.5.1/bin/x64/R CMD SHLIB file1f0443101b35.cpp 2> file1f0443101b35.cpp.err.txt' had status 1

Is there something I am missing?

This isn’t going to work for a few days. You can either try installing rstan from GitHub with

devtools::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")

after making sure that your ~/.R/Makevars file defines

CXX14=g++

Or you can try installing StanHeaders 2.17.x from source or you can probably still get a Windows binary version off of a CRAN mirror that hasn’t updated yet.

@bgoodri Thanks a lot.
I tried the first approach (modified .Makevars and tried re-installing ‘rstan’ from Git) - it didn’t work. The second solution, installing StanHeaders 2.17.x from a binary version did solve the issue. Now my Stan models are running as before.

I am also getting the same error during after installing rstan:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! Warning message:
In system(cmd) : ‘make’ not found
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-35~1.1/bin/x64/R CMD SHLIB file398c5e6bc9c.cpp 2> file398c5e6bc9c.cpp.err.txt’ had status 1

Your Rtools is not installed or configured correctly, which is likely due to not using the latest frozen version or not checking the box to amend the PATH environmental variable when installing Rtools.