/usr/bin/ld: cannot find -lgfortran

4
我正在尝试安装一个R包,代码如下:
>  install.packages("mnormt")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/mnormt_1.5-5.tar.gz'
Content type 'application/x-gzip' length 37169 bytes (36 KB)
==================================================
downloaded 36 KB

* installing *source* package ‘mnormt’ ...
** package ‘mnormt’ successfully unpacked and MD5 sums checked
** libs
gfortran   -fpic  -g -O2 -fstack-protector-strong  -c biv-nt.f -o biv-nt.o
gfortran   -fpic  -g -O2 -fstack-protector-strong  -c sadmvnt.f -o sadmvnt.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o mnormt.so biv-nt.o sadmvnt.o -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'mnormt.so' failed
make: *** [mnormt.so] Error 1
ERROR: compilation failed for package ‘mnormt’
* removing ‘/usr/local/lib/R/site-library/mnormt’

The downloaded source packages are in
        ‘/tmp/RtmpQnOaAx/downloaded_packages’
Warning message:
In install.packages("mnormt") :
  installation of package ‘mnormt’ had non-zero exit status

但是我已经安装了gfortran库。仍然出现这个错误。


1个回答

5

我怀疑你已经安装了libgfortran3,但没有安装libgfortran-5-dev。后者是构建使用该库的项目所必需的。在这种情况下,最好的解决方案是:

sudo apt-get install r-base-dev

这将安装libgfortran-5-dev和其他必要的软件包以构建CRAN软件包。
另外,您也可以使用:
sudo apt-get install r-cran-mnormt

并跳过二进制安装。

1
谢谢,我明白了!@Ralf - user8393448
我遇到了同样的错误,最终使用 ~$ sudo apt-get install libgfortran-* 安装了所有版本来解决它。这些 sudo apt-get install r-cran-mnormt 非常有用,可以让我们通过终端安装 :) - Rγσ ξηg Lιαη Ημ 雷欧

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接