我正在尝试安装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库。仍然是这个错误
答案 0 :(得分:1)
我怀疑您已安装libgfortran3
但未安装libgfortran-5-dev
。后者是使用库构建东西所必需的。在这种情况下,最好的解决方案是
sudo apt-get install r-base-dev
这将安装libgfortran-5-dev
以及构建CRAN软件包所必需的任何其他软件包。
或者您也可以使用
sudo apt-get install r-cran-mnormt
并跳过二进制安装。