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