2017-06-20 127 views
2

我試着install.packages("samr"),但它看起來像是試圖使用Fortran編譯文件,但我的Fortran看起來並沒有在指定的路徑上安裝程序,我的Fortran是從brew install gcc(我相信正確的路徑是/usr/local/Cellar/gcc/7.1.0/lib/gcc/7)。這是我的錯誤:編譯R包samr時出錯:`ld:找不到-lgfortran的庫

install.packages("samr") 
--- Please select a CRAN mirror for use in this session --- 
Package which is only available in source form, and may need 
    compilation of C/C++/Fortran: ‘samr’ 
Do you want to attempt to install these from sources? 
y/n: y 
installing the source package ‘samr’ 

trying URL 'https://cloud.r-project.org/src/contrib/samr_2.0.tar.gz' 
Content type 'application/x-gzip' length 36702 bytes (35 KB) 
================================================== 
downloaded 35 KB 

* installing *source* package ‘samr’ ... 
** libs 
gfortran -fPIC -g -O2 -c rankcol.f -o rankcol.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 samr.so rankcol.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: *** [samr.so] Error 1 
ERROR: compilation failed for package ‘samr’ 
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/samr’ 

The downloaded source packages are in 
    ‘/private/var/folders/v_/n5nqr5812074ct0zkldqhg500000gn/T/RtmpBn8P5n/downloaded_packages’ 
Warning message: 
In install.packages("samr") : 
    installation of package ‘samr’ had non-zero exit status 

回答

1

它看起來像環境特定的問題。我使用的日常R上3.3.3,我能夠沒有任何問題,安裝軟件包:

# this one is required by samr and is no longer available via CRAN 
source("https://bioconductor.org/biocLite.R") 
biocLite("impute") 
# samr, itself, can be installed from CRAN 
install.packages("samr") 
library(samr) 

不過,我使用略有不同的安裝gfortran的 - 直接從源:

https://gcc.gnu.org/wiki/GFortranBinaries

gfortran --version 
GNU Fortran (GCC) 6.3.0 
Copyright (C) 2016 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

,這就是gfortran的位置,同時從項目頁面安裝它

> which gfortran 
/usr/local/bin/gfortran 
> ls -l /usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0/ | wc -l 
     20 

也許你可以嘗試從項目頁面安裝它?不幸的是,在macOS的情況下,在R包(尤其是Java和Fortran)中有很多有力的假設。

+0

感謝您的回答我基本上做了同樣的事情,它的工作。在此之前,我還嘗試從他們的頁面直接下載並安裝它,但一直存在版本問題。但按照gcc.gnu.org的規定安裝gfortran似乎是解決方案。 –

+0

從gcc.gnu.org安裝gfortran爲我工作。 – jsb

+0

.oOo。涼!與Fortran玩得開心! ;).oOo。 – mko