Skip to content

A flawed Xcode installation?

2 messages · Vincent Carey, Peter Dalgaard

#
I frequently find that attempts to install R packages that include
C++ code encounter

/Users/.../Library/R/arm64/4.5/library/Rcpp/include/Rcpp/platform/compiler.h:37:10:
fatal error:
      'cmath' file not found
   37 | #include <cmath>
      |          ^~~~~~~

To rectify this, I manually prefix to the call to R with

PKG_CXXFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1

Is there a configuration step I am missing?  I believe this is a stock
installation of the R binary from CRAN, and a conventional installation of
Xcode (16.4).
R version 4.5.1 (2025-06-13)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.7.2

Matrix products: default
BLAS:
/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib

LAPACK:
/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;
 LAPACK version 3.12.1
#
My guess is that either it is the same issue as

https://stat.ethz.ch/pipermail/r-sig-mac/2024-September/015042.html

or there is a mismatch in the clang installation (Apple gratuitously updated to clang 17 in the middle of the Xcode 16.x series, and the 4.5.x binaries are still built with clang 16).

-pd