![](/img/trans.png)
[英]How do I install the ODBC driver for Snowflake successfully on an M1 Apple Silicon Mac?
[英]How to install RcppArmadillo on Apple Silicon (M1) Macs
我一直在嘗試許多不同的方法來安裝 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’
顯然,我沒有x86_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
我想我發現了一個問題。 首先,我遵循本教程: R COMPILER TOOLS FOR RCPP ON MACOS
完成后,它給了我幾乎與您在帖子中提到的相同的錯誤:
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)
看來,R 正在/opt/R/arm64
文件夾中尋找 gfortran。
在教程中,它表示 gfortran 安裝在/usr/local/gfortran
文件夾中。
我在/opt/R/arm64
中創建了一個符號鏈接,它使用命令引用/usr/local/gfortran
ln -s /usr/local/gfortran /opt/R/arm64
可以將~/.R/Makevars
FLIBS
的 FLIBS 設置為以下選項之一
# homebrew gfortran
FLIBS=-L/opt/homebrew/opt/gfortran/lib
# gfortran included in R
FLIBS=-L/opt/R/arm64/gfortran/lib
此外,可能還想將F77
和FC
定義為
F77 = /opt/R/arm64/gfortran/bin/gfortran
FC = /opt/R/arm64/gfortran/bin/gfortran
為了驗證,嘗試安裝glmnet
package 現在應該成功了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.