Cannot compile R packages with c++ code after updating to macOS Catalina

前端 未结 2 891
遇见更好的自我
遇见更好的自我 2020-11-30 15:12

I just updated to macOS Catalina and tried to compile an R package I am developing. However, now it does not work. I am not sure it is because of the OS or because of the

相关标签:
2条回答
  • You likely need to reinstall command line tools -- Apple often uninstalls them after OS updates. Try running:

    xcode-select --install
    

    in the terminal. (Note that, even if you're using the R-provided LLVM toolchain, it will still require access to the default system headers, and those are installed as part of the command line tools toolchain)

    EDIT: @coatless is spot on. In particular, from https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/, you need to set up your ~/.R/Makevars to point to the system headers:

    mkdir -p ~/.R
    
    # Fill with appropriate flag statements
    cat <<- EOF > ~/.R/Makevars
    # clang: start
    CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
    CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
    CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
    # clang: end
    EOF
    

    Note that R 3.6.1 patched does this by default -- e.g. I have in my $(R RHOME)/etc/Makeconf:

    CPPFLAGS = -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include
    
    0 讨论(0)
  • 2020-11-30 15:44

    Please use either:

    https://github.com/coatless/r-macos-rtools/releases/latest

    Or go through the steps by hand:

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

    The main change required for this version of macOS is the need to set flags to the header locations as no SDK kits are available to reinstall into the expected directories for R.

    0 讨论(0)
提交回复
热议问题