1

At some point, I cannot use C++ in R, especially when I execute Rcpp code. For example, I tried this

library(Rcpp)
evalCpp("1+1")

and got the result below:

ld: framework not found CoreFoundation
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_2.so] Error 1
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I"/private/var/folders/j3/5nhzd6x55mz7669q5mfs924m0000gn/T/RtmpXfWJxP/sourceCpp-x86_64-apple-darwin17.0-1.0.5" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include   -fPIC  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c fileb8a94984da1.cpp -o fileb8a94984da1.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o sourceCpp_2.so fileb8a94984da1.o /usr/local/Cellar/gettext/0.21/lib -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.

WARNING: The tools required to build C++ code for R were not found.

Please install Command Line Tools for XCode (or equivalent).

I installed the command line tools from this website, but still got an error. I guess the key hint is WARNING: The tools required to build C++ code for R were not found? However, I'm afraid I don't know how to handle this. I've searched for several postings, but none of them worked for my case.

Any advice?

FYI, I'm using

  • Mac OS Big Sur ver 11.0.1.
  • R ver 4.0.3
  • R studio ver 1.1.419
  • Rcpp package ver 1.0.5
desertnaut
  • 57,590
  • 26
  • 140
  • 166
inmybrain
  • 386
  • 3
  • 16
  • 1
    Have you tried this: https://github.com/rmacoslib/r-macos-rtools or seen this question: https://stackoverflow.com/q/58313047/4408538 – Joseph Wood Dec 12 '20 at 17:21
  • From [this SO answer](https://stackoverflow.com/a/58313170/4008219): >you need to set up your `~/.R/Makevars` to point to the system headers – inmybrain Dec 13 '20 at 01:04

0 Answers0