编译RcppArmadillo时遇到问题-找不到库gfortran

时间:2019-03-09 02:25:16

标签: r rcpparmadillo

运行:

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

因此,它毕竟不会安装。我在此链接cannot compile RcppArmadillo in R上进行了阅读,但由于不了解该怎么做,因此无法解决。您能发表评论吗?

我什至尝试这样做

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 package installation depends on gfortran-4.8

1 个答案:

答案 0 :(得分:1)

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

sudo apt-get install libgfortan5 libgfortan-8-dev