首页 > 解决方案 > 编译 RcppArmadillo 时遇到问题 - 未找到库 gfortran

问题描述

跑步:

install.packages("RcppArmadillo")

我收到以下错误:

ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
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/3.5/Resources/library/RcppArmadillo’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppArmadillo’

The downloaded source packages are in
    ‘/private/var/folders/x8/mrn18h_50g78zbq2jrxcwkx00000gn/T/RtmpK4nz32/downloaded_packages’
Warning messages:
1: In install.packages(update[instlib == l, "Package"], l, repos = repos,  :
  installation of package ‘coin’ had non-zero exit status
2: In install.packages(update[instlib == l, "Package"], l, repos = repos,  :
  installation of package ‘Matrix’ had non-zero exit status
3: In install.packages(update[instlib == l, "Package"], l, repos = repos,  :
  installation of package ‘RcppArmadillo’ had non-zero exit status

所以它毕竟没有安装它。我在此链接上阅读了无法在 R 中编译 RcppArmadillo但我无法解决此问题,因为我不明白该怎么做。你能请评论吗?

我什至试图这样做

install.packages("https://cran.r-project.org/src/contrib/Archive/RcppArmadillo/RcppArmadillo_0.6.100.0.0.tar.gz", repos=NULL, type="source")

出现了同样的错误


感谢 JPR,我找到了帮助我解决问题的答案。所以如果你使用linux,使用他的命令行,如果你使用Mac,按照这个帖子安装运行时库

OS X 包安装依赖 gfortran-4.8

标签: rrcpparmadillo

解决方案


您的机器上缺少运行时库。只需尝试

sudo apt-get install libgfortan5 libgfortan-8-dev

推荐阅读