r - 如何在 Apple Silicon (M1) Mac 上安装 RcppArmadillo
问题描述
我一直在尝试许多不同的方法来安装 RcppArmadillo,但我没有让它工作
install.packages(c('Rcpp'))
Sys.setenv("PKG_CXXFLAGS"="-std=c++11")
install.packages(c('RcppArmadillo'),type = "source")
它给了我这个错误:
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [RcppArmadillo.so] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo’
显然,自从我为 Apple Silicon Architecturex86_64-apple-darwin18/8.2.0
安装了 gfortran 之后,我就没有了。
Mac版:
macOS Big Sur
11.2.3
Apple M1
R版本:
version
_
platform x86_64-apple-darwin17.0
arch x86_64
os darwin17.0
system x86_64, darwin17.0
status
major 4
minor 0.4
year 2021
month 02
day 15
svn rev 80002
language R
version.string R version 4.0.4 (2021-02-15)
nickname Lost Library Book
解决方案
可以设置FLIBS
为~/.R/Makevars
以下选项之一
# homebrew gfortran
FLIBS=-L/opt/homebrew/opt/gfortran/lib
# gfortran included in R
FLIBS=-L/opt/R/arm64/gfortran/lib
此外,可能还想将F77
and定义FC
为
F77 = /opt/R/arm64/gfortran/bin/gfortran
FC = /opt/R/arm64/gfortran/bin/gfortran
要验证,请尝试安装glmnet
现在应该成功的包。
推荐阅读
- javascript - 触发关键字功能的输入框
- javascript - TypeScript:如何仅将“allowSyntheticDefaultImports”应用于 node_modules?
- javascript - 修复不同大小的图块和精灵抖动的显示舍入错误
- php - 没有可用于包“pecl.php.net/mongodb”的版本
- kubernetes - Kubeflow 在本地设置(笔记本电脑/台式机)上缺少 .kube/config 文件
- sql - Postgresql:`pg_catalog.pg_stat_get_numscans` 需要 10 秒以上
- pytorch - 使用 s3 路径时如何避免将 tensorboard 日志写入本地目录?
- javascript - 带有 webpack + socket.io 的服务器/客户端应用程序
- apache - httpd.conf 和 logserver.conf 不能同时工作 - 它们使用相同的 PID (Linux)
- javascript - 如何在嵌套函数 React (navigator.geolocation.getCurrentPosition()) 中返回值