为什么 kernlab 软件包无法通过 GCC 安装在我的 MacOS 上?

问题描述 投票:0回答:1

我一直在尝试安装“kernlab”包,因为我正在尝试学习机器学习并需要它来支持向量机模型。我通过 Homebrew 下载了 GCC-13,它存储在 /opt/homebrew/opt 中(我知道这是一个非典型的下载位置)。我还制作了自己的 Makevars 文件,与 Rodrigo Zepeda 的博客一致(https://rodzepeda.medium.com/fixing-macos-catalinas-mess-when-trying-to-compile-almost-any-r-package-d94a063d64eb )。我有 MacOS Sonoma 14.4.1(最新版本)、RStudio/2024.04.0+735 和 gcc-13。但是,当我去安装该软件包时,出现此错误:

> install.packages("kernlab")
Warning in install.packages :
  unable to access index for repository http://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1:
  cannot open URL 'http://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1/PACKAGES'
Package which is only available in source form,
  and may need compilation of C/C++/Fortran:
  ‘kernlab’
Do you want to attempt to install these from sources? (Yes/no/cancel) Y
installing the source package ‘kernlab’

trying URL 'http://cran.rstudio.com/src/contrib/kernlab_0.9-32.tar.gz'
Content type 'application/x-gzip' length 1215773 bytes (1.2 MB)
==================================================
downloaded 1.2 MB

* installing *source* package ‘kernlab’ ...
** package ‘kernlab’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/opt/homebrew/opt/llvm/bin/clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/homebrew/opt/icu4c/include -I/opt/homebrew/opt/libxml2/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpng/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/llvm/include -I/opt/homebrew/opt/openblas/include -I/opt/homebrew/opt/lapack/include -I/opt/homebrew/opt/tcl-tk/include -I/opt/homebrew/opt/udunits/include/ -I/opt/homebrew/opt/expat/include -I/opt/homebrew/opt/krb5/include -I/opt/homebrew/opt/libpq/include -I/opt/homebrew/opt/qt@5/include   -fPIC  -falign-functions=64 -Wall -g -O2  -c brweight.cpp -o brweight.o
In file included from brweight.cpp:41:
In file included from ./brweight.h:42:
In file included from ./errorcode.h:42:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/iostream:43:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/ios:223:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__locale:15:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__memory/shared_ptr.h:24:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__memory/allocation_guard.h:15:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__memory/allocator_traits.h:14:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__memory/construct_at.h:23:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/new:364:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/cstdlib:87:
/opt/homebrew/opt/llvm/bin/../include/c++/v1/stdlib.h:145:30: error: unknown type name 'ldiv_t'
  145 | inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }
      |                              ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/stdlib.h:145:82: error: no member named 'ldiv' in the global namespace
  145 | inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }
      |                                                                                ~~^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/stdlib.h:147:30: error: unknown type name 'lldiv_t'
  147 | inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); }
      |                              ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/stdlib.h:147:93: error: no member named 'lldiv' in the global namespace
  147 | inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); }
      |                                                                                           ~~^
In file included from brweight.cpp:41:
In file included from ./brweight.h:42:
In file included from ./errorcode.h:42:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/iostream:43:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/ios:223:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__locale:15:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__memory/shared_ptr.h:33:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__memory/unique_ptr.h:17:
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__functional/hash.h:40:8: error: reference to unresolved using declaration
   40 |   std::memcpy(&__r, __p, sizeof(__r));
      |        ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/cstring:80:1: note: using declaration annotated with 'using_if_exists' here
   80 | using ::memcpy _LIBCPP_USING_IF_EXISTS;
      | ^
In file included from brweight.cpp:41:
In file included from ./brweight.h:42:
In file included from ./errorcode.h:42:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/iostream:43:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/ios:223:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__locale:16:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__mutex/once_flag.h:21:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/tuple:272:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/compare:145:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__compare/compare_partial_order_fallback.h:13:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__compare/partial_order.h:14:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__compare/weak_order.h:14:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__compare/strong_order.h:20:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/cmath:319:
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:392:31: error: use of undeclared identifier 'FP_NAN'
  392 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                               ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:392:39: error: use of undeclared identifier 'FP_INFINITE'
  392 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                       ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:392:52: error: use of undeclared identifier 'FP_NORMAL'
  392 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                                    ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:392:63: error: use of undeclared identifier 'FP_SUBNORMAL'
  392 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                                               ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:392:77: error: use of undeclared identifier 'FP_ZERO'
  392 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                                                             ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:397:31: error: use of undeclared identifier 'FP_NAN'
  397 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                               ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:397:39: error: use of undeclared identifier 'FP_INFINITE'
  397 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                       ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:397:52: error: use of undeclared identifier 'FP_NORMAL'
  397 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                                    ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:397:63: error: use of undeclared identifier 'FP_SUBNORMAL'
  397 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                                               ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:397:77: error: use of undeclared identifier 'FP_ZERO'
  397 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                                                             ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:402:31: error: use of undeclared identifier 'FP_NAN'
  402 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                               ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:402:39: error: use of undeclared identifier 'FP_INFINITE'
  402 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                       ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:402:52: error: use of undeclared identifier 'FP_NORMAL'
  402 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                                    ^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:402:63: error: use of undeclared identifier 'FP_SUBNORMAL'
  402 |   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
      |                                                               ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [brweight.o] Error 1
ERROR: compilation failed for package ‘kernlab’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/kernlab’
Warning in install.packages :
  installation of package ‘kernlab’ had non-zero exit status`

到目前为止,我还没有找到任何有关如何解决此问题的信息。

到目前为止,我已经使用 Homebrew 卸载并重新安装了 gcc。我还尝试在不使用 Homebrew 的情况下安装 gcc,但对我来说并不是很成功,因为它导致了更多错误,并且终端中的文件更加混乱。当我重新安装 gcc 并第二次访问 Rodrigo 的论坛时,我又遇到了同样的错误(如上所述)。

这是我第一次在在线论坛上提问,所以如果我有什么遗漏的地方,请随时告诉我。如果您需要更多信息也很好。我真的很想解决这个问题!

r gcc homebrew clang++ kernlab
1个回答
0
投票

也许遵循这个可能会有所帮助:https://yiqingxu.org/public/BigSurError.pdf

如果您已经完成了这些步骤,很抱歉指出。我发现有时在 Mac 上涉及 gcc 的错误可以通过安装支持 OpenMP 的 XCode 来解决。我不知道情况是否如此,但也许值得尝试:

curl -O https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz && sudo tar fvxz openmp-12.0.1-darwin20-Release.tar.gz -C / && mkdir -p ~/.R && echo -e "CPPFLAGS += -Xclang -fopenmp\nLDFLAGS += -lomp" >> ~/.R/Makevars
我也很难尝试在 MacOS 上编译需要 gcc 的 R 包,所以如果这些方法不能解决问题并且你弄清楚了,请告诉我

© www.soinside.com 2019 - 2024. All rights reserved.