简体   繁体   English

如何在 Apple Silicon (M1) Mac 上安装 RcppArmadillo

[英]How to install RcppArmadillo on Apple Silicon (M1) Macs

I've been trying many different ways to install RcppArmadillo, but I don't get it to work我一直在尝试许多不同的方法来安装 RcppArmadillo,但我没有让它工作

install.packages(c('Rcpp'))
Sys.setenv("PKG_CXXFLAGS"="-std=c++11")
install.packages(c('RcppArmadillo'),type = "source")

It gives me this error:它给了我这个错误:

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’

Obviously, I don't have x86_64-apple-darwin18/8.2.0 since I installed gfortran for the apple silicon architecture .显然,我没有x86_64-apple-darwin18/8.2.0 ,因为我为苹果硅架构安装了 gfortran 。

Mac version: Mac版:

macOS Big Sur 
11.2.3
Apple M1

R version: 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           

I think I found an issue.我想我发现了一个问题。 First, I follow this tutorial: R COMPILER TOOLS FOR RCPP ON MACOS首先,我遵循本教程: R COMPILER TOOLS FOR RCPP ON MACOS
Once completed, it gaves me almost the same error as you mentioned in your post:完成后,它给了我几乎与您在帖子中提到的相同的错误:

ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/.....'
ld: library not found for -lgfortran clang: error: linker command failed
with exit code 1 (use -v to see invocation)

It seems, R is looking for gfortran in /opt/R/arm64 folder.看来,R 正在/opt/R/arm64文件夹中寻找 gfortran。
In the turorial it indicates that gfortran is installed in the /usr/local/gfortran folder.在教程中,它表示 gfortran 安装在/usr/local/gfortran文件夹中。
I created a symbolic link in the /opt/R/arm64 which refers to /usr/local/gfortran with the command我在/opt/R/arm64中创建了一个符号链接,它使用命令引用/usr/local/gfortran
ln -s /usr/local/gfortran /opt/R/arm64

One can set FLIBS in ~/.R/Makevars to one of the following options可以将~/.R/Makevars FLIBS的 FLIBS 设置为以下选项之一

# homebrew gfortran
FLIBS=-L/opt/homebrew/opt/gfortran/lib

# gfortran included in R
FLIBS=-L/opt/R/arm64/gfortran/lib

In addition one might want to also define F77 and FC as此外,可能还想将F77FC定义为

F77     = /opt/R/arm64/gfortran/bin/gfortran
FC      = /opt/R/arm64/gfortran/bin/gfortran

To verify, try installing the glmnet package which should now succeed.为了验证,尝试安装glmnet package 现在应该成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 M1 Apple Silicon Mac 上成功安装 Snowflake 的 ODBC 驱动程序? - How do I install the ODBC driver for Snowflake successfully on an M1 Apple Silicon Mac? MacOS Big Sur M1 芯片,R devtool monocle3 安装过程中出现 cmath 错误 - MacOS Big Sur M1 silicon, cmath error during R devtool monocle3 install 使用迁移助手从 Intel 迁移到 Apple Silicon M1 后使用 R 返回错误:Bad CPU type in executable and Undefined error: 0 - Using R after using migration assistant to move from Intel to Apple Silicon M1 returns errors: Bad CPU type in executable and Undefined error: 0 如何在具有 M1 架构的 Mac 中安装 rJava package - How to install rJava package in Mac with M1 architecture 如何在 AWS EMR 5.29 版中安装 RcppArmadillo - How to install RcppArmadillo in AWS EMR version 5.29 无法在 m1 mac 上的 R 中安装“robustHD” - Not able to install "robustHD" in R on m1 mac Apple 芯片上的 R 和 Rstudio - R and Rstudio on Apple silicon RcppArmadillo:未能在CentOS上安装 - RcppArmadillo: failing to install on CentOS 在带有 Apple M1 芯片的 MacBook 上安装 gfortran 以用于 R - Installing gfortran on MacBook with Apple M1 chip for use in R 无法在 MacOS M1 Monterey 上安装 stringi R 包 - Unable to install stringi R package on MacOS M1 Monterey
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM