0

Trying to get Rcpp to work on R 4.1.2 on Mac OS Monterey using an Intel computer.

> 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

I have followed Coatless Professor's instructions:

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

I believe Xcode Command Line Tools and gfortran are installed:

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

and I have removed both ~/.R/Makevars and ~/.Renviron.

Any help would be much appreciated -- thanks so much!

Bob
  • 179
  • 2
  • 11

1 Answers1

3

There is an old reference to a prior version of the clang compiler present.

In R, please type:

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

Please restart R and, then, try:

Rcpp::evalCpp("1+1")
coatless
  • 20,011
  • 13
  • 69
  • 84
  • Yay, it worked, thank you *so* much! I assumed removing the files was the same as `unlink`, but clearly I should have followed your instructions more carefully. Thank you very much again! – Bob Jan 17 '22 at 08:03