Rcpp 无法在 Mac OS Monterey, R 4.1.2. 上编译,clang 错误

Rcpp does not compile on Mac OS Monterey, R 4.1.2., clang error

尝试使用 Intel 计算机让 Rcpp 在 Mac OS Monterey 上的 R 4.1.2 上工作。

> library(Rcpp)
> evalCpp("2 + 2")
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include" -I"/private/var/folders/jz/977gqfr957g_rlgw1h05152w0000gq/T/Rtmp8hmDZ5/sourceCpp-x86_64-apple-darwin17.0-1.0.8" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include   -fPIC  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c file152f71a55f97c.cpp -o file152f71a55f97c.o
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o sourceCpp_2.so file152f71a55f97c.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir,  : 
  Error 1 occurred building shared library.
clang: error: no such file or directory: '/Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib'
make: *** [sourceCpp_2.so] Error 1

我已遵循 Coatless 教授的指示:

https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/

我相信 Xcode 命令行工具和 gfortran 已安装:

$which gcc 
/usr/bin/gcc
$which gfortran 
/usr/local/bin/gfortran

我已经删除了 ~/.R/Makevars~/.Renviron

如有任何帮助,我们将不胜感激 - 非常感谢!

存在对 clang 编译器先前版本的旧引用。

R中,请输入:

unlink("~/.R/Makevars")
unlink("~/.Renviron")

请重新启动 R,然后尝试:

Rcpp::evalCpp("1+1")