gpt4 book ai didi

r - 更新到 macOS Catalina 后无法使用 C++ 代码编译 R 包

转载 作者:行者123 更新时间:2023-12-01 17:07:03 26 4
gpt4 key购买 nike

我刚刚更新到 macOS Catalina 并尝试编译 an R package我正在发展。然而,现在它不起作用了。我不确定这是因为操作系统还是因为 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

这是我的 session 信息。

> 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

谢谢!

最佳答案

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

xcode-select --install

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

编辑:@coatless 是正确的。特别是来自https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/ ,您需要设置 ~/.R/Makevars 以指向系统 header :

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

关于r - 更新到 macOS Catalina 后无法使用 C++ 代码编译 R 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58313047/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com