Почему пакет kernlab не устанавливается на мою MacOS через GCC?

Я пытался установить пакет «kernlab», поскольку пытаюсь изучить машинное обучение и нуждаюсь в нем для моделей машин опорных векторов. У меня есть GCC-13, загруженный через Homebrew, и он хранится в /opt/homebrew/opt (который, как я знаю, является нетипичным местом для его загрузки). Я также создал свой собственный файл Makevars, соответствующий блогу Родриго Зепеды (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`

Пока мне не удалось найти никакой информации о том, как это исправить.

На данный момент я удалил и переустановил gcc с помощью Homebrew. Я также пытался установить gcc без Homebrew, но мне это не удалось, так как это привело к еще большему количеству ошибок и еще большей путанице с файлами в Терминале. Когда я переустановил gcc и во второй раз проследил за форумом Родриго, я вернулся к тем же ошибкам, которые у меня были (как указано выше).

Я впервые задаю вопрос на онлайн-форуме, поэтому, если я что-то пропустил, не стесняйтесь, дайте мне знать. Если вам нужно больше информации, это тоже хорошо. Я просто очень хочу решить эту проблему!

Ошибки показывают, что используется clang, а не gcc. Никаких доказательств gcc.

n. m. could be an AI 08.05.2024 09:51
Стоит ли изучать PHP в 2026-2027 годах?
Стоит ли изучать PHP в 2026-2027 годах?
Привет всем, сегодня я хочу высказать свои соображения по поводу вопроса, который я уже много раз получал в своем сообществе: "Стоит ли изучать PHP в...
Поведение ключевого слова "this" в стрелочной функции в сравнении с нормальной функцией
Поведение ключевого слова "this" в стрелочной функции в сравнении с нормальной функцией
В JavaScript одним из самых запутанных понятий является поведение ключевого слова "this" в стрелочной и обычной функциях.
Приемы CSS-макетирования - floats и Flexbox
Приемы CSS-макетирования - floats и Flexbox
Здравствуйте, друзья-студенты! Готовы совершенствовать свои навыки веб-дизайна? Сегодня в нашем путешествии мы рассмотрим приемы CSS-верстки - в...
Тестирование функциональных ngrx-эффектов в Angular 16 с помощью Jest
В системе управления состояниями ngrx, совместимой с Angular 16, появились функциональные эффекты. Это здорово и делает код определенно легче для...
Концепция локализации и ее применение в приложениях React ⚡️
Концепция локализации и ее применение в приложениях React ⚡️
Локализация - это процесс адаптации приложения к различным языкам и культурным требованиям. Это позволяет пользователям получить опыт, соответствующий...
Пользовательский скаляр GraphQL
Пользовательский скаляр GraphQL
Листовые узлы системы типов GraphQL называются скалярами. Достигнув скалярного типа, невозможно спуститься дальше по иерархии типов. Скалярный тип...
0
1
57
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Возможно, это может помочь: https://yiqingxu.org/public/BigSurError.pdf

Если вы уже выполнили эти шаги, извините, что указали на это. Я видел, что иногда ошибки, связанные с gcc на Mac, решаются установкой XCode с поддержкой OpenMP. Не знаю, так ли это, но, возможно, стоит попробовать:

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

Мне также было трудно скомпилировать пакеты R, для которых требуется gcc в MacOS, поэтому, если они не решат проблему и вы разберетесь, дайте мне знать.

Другие вопросы по теме