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

你说的曾经没有我的故事 提交于 2021-01-24 09:42:06

问题


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 Rcpp package. Any help would be appreciated!

> devtools::load_all(".")
Loading phyr
Re-compiling phyr
─  installing *source* package ‘phyr’ ...
   ** using staged installation
   ** libs
   /usr/local/clang4/bin/clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Users/dli/R/Rcpp/include" -I"/Users/dli/R/RcppArmadillo/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
   In file included from RcppExports.cpp:4:
   In file included from /Users/dli/R/RcppArmadillo/include/RcppArmadillo.h:31:
   In file included from /Users/dli/R/RcppArmadillo/include/RcppArmadilloForward.h:26:
   In file included from /Users/dli/R/Rcpp/include/RcppCommon.h:29:
   In file included from /Users/dli/R/Rcpp/include/Rcpp/r/headers.h:59:
   In file included from /Users/dli/R/Rcpp/include/Rcpp/platform/compiler.h:100:
   /usr/local/clang4/bin/../include/c++/v1/cmath:313:9: error: no member named 'signbit' in the global namespace
   using ::signbit;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:314:9: error: no member named 'fpclassify' in the global namespace
   using ::fpclassify;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:315:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
   using ::isfinite;
         ~~^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: 'finite' declared here
   extern int finite(double)
              ^
   In file included from RcppExports.cpp:4:
   In file included from /Users/dli/R/RcppArmadillo/include/RcppArmadillo.h:31:
   In file included from /Users/dli/R/RcppArmadillo/include/RcppArmadilloForward.h:26:
   In file included from /Users/dli/R/Rcpp/include/RcppCommon.h:29:
   In file included from /Users/dli/R/Rcpp/include/Rcpp/r/headers.h:59:
   In file included from /Users/dli/R/Rcpp/include/Rcpp/platform/compiler.h:100:
   /usr/local/clang4/bin/../include/c++/v1/cmath:316:9: error: no member named 'isinf' in the global namespace
   using ::isinf;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:317:9: error: no member named 'isnan' in the global namespace
   using ::isnan;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:318:9: error: no member named 'isnormal' in the global namespace
   using ::isnormal;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:319:9: error: no member named 'isgreater' in the global namespace
   using ::isgreater;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:320:9: error: no member named 'isgreaterequal' in the global namespace
   using ::isgreaterequal;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:321:9: error: no member named 'isless' in the global namespace
   using ::isless;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:322:9: error: no member named 'islessequal' in the global namespace
   using ::islessequal;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:323:9: error: no member named 'islessgreater' in the global namespace
   using ::islessgreater;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:324:9: error: no member named 'isunordered' in the global namespace
   using ::isunordered;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:325:9: error: no member named 'isunordered' in the global namespace
   using ::isunordered;
         ~~^
   /usr/local/clang4/bin/../include/c++/v1/cmath:331:9: error: no member named 'abs' in the global namespace; did you mean 'fabs'?
   using ::abs;
         ~~^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:417:15: note: 'fabs' declared here
   extern double fabs(double);
                 ^
   In file included from RcppExports.cpp:4:
   In file included from /Users/dli/R/RcppArmadillo/include/RcppArmadillo.h:31:
   In file included from /Users/dli/R/RcppArmadillo/include/RcppArmadilloForward.h:26:
   In file included from /Users/dli/R/Rcpp/include/RcppCommon.h:29:
   In file included from /Users/dli/R/Rcpp/include/Rcpp/r/headers.h:59:
   In file included from /Users/dli/R/Rcpp/include/Rcpp/platform/compiler.h:100:
   /usr/local/clang4/bin/../include/c++/v1/cmath:557:28: error: expected a qualified name after 'typename'
   _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
                              ^
   /usr/local/clang4/bin/../include/c++/v1/cmath:557:37: error: expected ';' at end of declaration
   _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
                                       ^
   /usr/local/clang4/bin/../include/c++/v1/cmath:557:37: error: expected unqualified-id
   /usr/local/clang4/bin/../include/c++/v1/cmath:569:39: error: use of undeclared identifier 'is_floating_point'
   _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
                                         ^
   /usr/local/clang4/bin/../include/c++/v1/cmath:569:57: error: '_A1' does not refer to a value
   _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
                                                           ^
   /usr/local/clang4/bin/../include/c++/v1/cmath:567:17: note: declared here
   template <class _A1>
                   ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   20 errors generated.
   make: *** [RcppExports.o] Error 1
   ERROR: compilation failed for package ‘phyr’
─  removing ‘/private/var/folders/b0/zl5p7whd1zg4cwk9q1nc69_h0000gn/T/RtmpE8aUBf/devtools_install_2b457078750/phyr’
Error in (function (command = NULL, args = character(), error_on_status = TRUE,  : 
  System command error

Here is my session information.

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2                compiler_3.6.1            prettyunits_1.0.2        
 [4] remotes_2.1.0             tools_3.6.1               testthat_2.2.1           
 [7] digest_0.6.21             pkgbuild_1.0.6            pkgload_1.0.2            
[10] memoise_1.1.0             nlme_3.1-140              lattice_0.20-38          
[13] mgcv_1.8-28               rlang_0.4.0               Matrix_1.2-17            
[16] cli_1.1.0                 rstudioapi_0.10           parallel_3.6.1           
[19] RcppArmadillo_0.9.700.2.0 withr_2.1.2               cluster_2.1.0            
[22] fs_1.3.1                  desc_1.2.0                devtools_2.2.1           
[25] rprojroot_1.3-2           grid_3.6.1                glue_1.3.1               
[28] R6_2.4.0                  processx_3.4.1            sessioninfo_1.1.1        
[31] callr_3.3.2               magrittr_1.5              backports_1.1.5          
[34] ps_1.3.0                  ellipsis_0.3.0            MASS_7.3-51.4            
[37] splines_3.6.1             usethis_1.5.1             assertthat_0.2.1         
[40] permute_0.9-5             picante_1.8               ape_5.3                  
[43] crayon_1.3.4              vegan_2.5-6              

Thanks!


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/65047685/r-package-installation-fail-ld-framework-not-found-corefoundation-clang-7-err

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!