我尝试通过以下方式安装“ DistributionUtils”软件包(在Mac上)
install.packages("DistributionUtils")
询问我是否要从源代码安装这些文件。我回答“是”(注意:回答“否”时,代码不会继续进行安装)。然后,发生以下错误(请参见下面的完整代码):
make: *** [IncompleteBessel.o] Error 1
ERROR: compilation failed for package ‘DistributionUtils’
两个问题:
感谢您的帮助。请在下面找到完整的执行代码:
install.packages("DistributionUtils")
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6:
cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
Package which is only available in source form, and may need compilation of C/C++/Fortran:
‘DistributionUtils’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source package ‘DistributionUtils’
trying URL 'https://cran.rstudio.com/src/contrib/DistributionUtils_0.6-0.tar.gz'
Content type 'application/x-gzip' length 41231 bytes (40 KB)
==================================================
downloaded 40 KB
* installing *source* package ‘DistributionUtils’ ...
** package ‘DistributionUtils’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -fPIC -Wall -g -O2 -c IncompleteBessel.f -o IncompleteBessel.o
make: gfortran: No such file or directory
make: *** [IncompleteBessel.o] Error 1
ERROR: compilation failed for package ‘DistributionUtils’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/DistributionUtils’
Warning in install.packages :
installation of package ‘DistributionUtils’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/pp/nll33qgs6w52y4bkhjdxvvdh0000gn/T/RtmpTZoRq5/downloaded_packages’
––––––––––––––––––––
编辑:按照Konard Rudolph的建议,我通过Homebrew安装了GCC。但是,它仍然无法正常工作,我现在收到以下错误:
install.packages("DistributionUtils")
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6:
cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘DistributionUtils’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source package ‘DistributionUtils’
trying URL 'https://cran.rstudio.com/src/contrib/DistributionUtils_0.6-0.tar.gz'
Content type 'application/x-gzip' length 41231 bytes (40 KB)
==================================================
downloaded 40 KB
* installing *source* package ‘DistributionUtils’ ...
** package ‘DistributionUtils’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -fPIC -Wall -g -O2 -c IncompleteBessel.f -o IncompleteBessel.o
IncompleteBessel.f:117:36:
117 | subroutine GNUM(n,x,y,nu,Am,An,nmax,Cnp,GM,GN)
| 1
Warning: Unused dummy argument 'an' at (1) [-Wunused-dummy-argument]
IncompleteBessel.f:34:34:
34 | double precision BI(0:numax),BK(0:numax)
| 1
Warning: Unused variable 'bi' declared at (1) [-Wunused-variable]
IncompleteBessel.f:34:46:
34 | double precision BI(0:numax),BK(0:numax)
| 1
Warning: Unused variable 'bk' declared at (1) [-Wunused-variable]
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c init.c -o init.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o DistributionUtils.so IncompleteBessel.o init.o -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
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: *** [DistributionUtils.so] Error 1
ERROR: compilation failed for package ‘DistributionUtils’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/DistributionUtils’
Warning in install.packages :
installation of package ‘DistributionUtils’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/pp/nll33qgs6w52y4bkhjdxvvdh0000gn/T/RtmpA1L5oK/downloaded_packages’
答案 0 :(得分:1)
(Q1)为什么会发生错误?
如错误消息所述,发生错误是因为尚未安装GNU Fortran编译器(gfortran
)。安装警告您从源安装时可能需要这样做:
仅以源格式提供的软件包,可能需要对C / C ++ / Fortran进行编译: ‘DistributionUtils’
(Q2)我该如何交替安装软件包?
您需要安装软件包的外部依赖项。换句话说,您需要安装GCC,gfortran
是其中的一部分。最简单的方法是via Homebrew。