r -/usr/bin/ld : cannot find -lgfortran

标签 r shared-libraries ubuntu-16.04

我正在尝试安装 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 库。还是这个错误

最佳答案

我怀疑你安装了libgfortran3但不是 libgfortran-5-dev .后者是使用库构建事物所必需的。在这种情况下最好的解决方案是

sudo apt-get install r-base-dev

这将安装 libgfortran-5-dev以及构建 CRAN 包所必需的任何其他包。

或者你也可以使用
sudo apt-get install r-cran-mnormt

并跳过二进制安装。

关于r -/usr/bin/ld : cannot find -lgfortran,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50562112/

相关文章:

r - R(或任何语言)中偏态正态分布的非线性最小二乘回归

r - 从数据框中的两个字符类型行的组合创建一个新行

linux - dpkg-buildpackage 错误 : missing files (usr/include/*)

shell - 有没有办法在 linux 的 conf 文件中将文本添加到字符串的末尾?

c++ - 同一个库在16.04下和14.04下定义了不同的符号

r - 如何从表中计算 A 发生和 B 与 R 发生的次数?

c++ - 编译失败,出现 "relocation R_X86_64_32 against ` .rodata.str1。 8' can not be used when making a shared object"

gcc - 为 Julia 中的 C lib 使用构建 C 包装器

docker - 由于 docker/cron,设备上没有剩余空间

r - Keras 如何预测 11106 个不同客户的(单独)销售序列,每个客户都有一系列不同的长度(从 1 到 15 个周期)