Installing Stanheaders can't find stdio.h file

I am trying to install the R Stanheaders package. When I do so, I get the following error:

clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DNO_FPRINTF_OUTPUT -I"…/inst/include" -I"sundials" -include stan_sundials_printf_override.hpp -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS -DSTRICT_R_HEADERS -DUSE_PTHREAD -I’/Users/bcl206/Documents/GitHub/incidenceinflation_paper/renv/library/R-4.1/x86_64-apple-darwin17.0/RcppEigen/include’ -I’/Users/bcl206/Documents/GitHub/incidenceinflation_paper/renv/library/R-4.1/x86_64-apple-darwin17.0/RcppParallel/include’ -I/usr/local/include -fPIC -Wall -g -O2 -c cvodes/cvodea.c -o cvodes/cvodea.o
cvodes/cvodea.c:25:10: fatal error: ‘stdio.h’ file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
make: *** [cvodes/cvodea.o] Error 1

I have taken a look in usr/local/include and found it didn’t contain stdio.h, so I wondered if this was the issue?

My session info is:

R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] Rcpp_1.0.12 pillar_1.9.0
[3] compiler_4.1.2 cmdstanr_0.7.1
[5] prettyunits_1.2.0 tools_4.1.2
[7] pkgbuild_1.4.2 lifecycle_1.0.3
[9] tibble_3.2.1 gtable_0.3.4
[11] checkmate_2.2.0 pkgconfig_2.0.3
[13] rlang_1.1.1 DBI_1.1.3
[15] cli_3.6.1 rstudioapi_0.15.0
[17] parallel_4.1.2 xfun_0.40
[19] loo_2.6.0 gridExtra_2.3
[21] dplyr_1.1.3 knitr_1.44
[23] generics_0.1.3 vctrs_0.6.4
[25] stats4_4.1.2 grid_4.1.2
[27] tidyselect_1.2.0 inline_0.3.19
[29] glue_1.6.2 R6_2.5.1
[31] processx_3.8.2 fansi_1.0.5
[33] distributional_0.3.2 rstan_2.21.8
[35] incidenceinflationstan_0.0.0.9000 tensorA_0.36.2
[37] callr_3.7.3 ggplot2_3.4.4
[39] farver_2.1.1 purrr_1.0.2
[41] posterior_1.4.1 magrittr_2.0.3
[43] codetools_0.2-18 matrixStats_1.0.0
[45] StanHeaders_2.21.0-7 backports_1.4.1
[47] scales_1.2.1 ps_1.7.5
[49] abind_1.4-5 colorspace_2.1-0
[51] renv_1.0.3 utf8_1.2.4
[53] RcppParallel_5.1.7 munsell_0.5.0
[55] crayon_1.5.2 incidenceinflation_0.0.0.9000

Hi, @Ben_Lambert. Which compiler are you using and can it compile C++ files that use stdio.h? And which Mac OS? It sounds like Catalina introduced some problems around this.

If you’re using Xcode, have you installed the command line tools? The error messages for when it’s not installed are horrible.

It sounds like it’s failing to find the standard library and stdio.h is just the first thing to pop up. There’s a lot of indirection in the way Mac OS X stores these files judging from spotlight on my machine, so I doubt not having the file around is the problem.

Lots of reports online just reinstall Xcode and fix the problem.

I don’t know why this is calling clang rather than clang++, but I doubt that’s the issue.

Thanks, Bob. It turned out that it was Anaconda that had modified my PATH to point towards the wrong compiler!