Warm tip: This article is reproduced from serverfault.com, please click

其他-更新到macOS Catalina后无法使用C ++代码编译R软件包

(其他 - Cannot compile R packages with c++ code after updating to macOS Catalina)

发布于 2019-10-09 22:22:12

我刚刚更新到macOS Catalina,并尝试编译我正在开发的R软件包但是,现在不起作用。我不确定是因为操作系统还是Rcpp程序包。任何帮助,将不胜感激!

> 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

这是我的会议信息。

> 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              

谢谢!

Questioner
Daijiang Li
Viewed
11
Kevin Ushey 2019-10-10 08:45:15

你可能需要重新安装命令行工具-Apple经常在操作系统更新后卸载它们。尝试运行:

xcode-select --install

在终端。(请注意,即使你使用的是R提供的LLVM工具链,它仍然需要访问默认的系统头,并且这些头是作为命令行工具工具链的一部分安装的)

编辑:@coatless是当场。特别是,从https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/中,你需要进行设置~/.R/Makevars以指向系统头:

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

请注意,默认情况下,已修补R 3.6.1的代码会执行此操作-例如,我在自己的计算机中$(R RHOME)/etc/Makeconf

CPPFLAGS = -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include