De-Novo
De-Novo

Reputation: 31

Error compiling R package samr: `ld: library not found for -lgfortran`

Im trying install.packages("samr")but it looks like its trying to compile the file using Fortran, but my Fortran doesn't seem to be on the path specified by the installer, my Fortran is from brew install gcc (I belive the correct path to be /usr/local/Cellar/gcc/7.1.0/lib/gcc/7). This is my error messge:

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

Upvotes: 2

Views: 3169

Answers (1)

Oo.oO
Oo.oO

Reputation: 13435

It looks like environment specific issue. I am using R 3.3.3 on daily basis and I was able to install the package without any issues:

# 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)

However, I am using slightly different installation of gfortran - directly from the source:

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.

and that's the location of gfortran while installing it from project page

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

Maybe you can try installing it from the project page? Unfortunately, in case of macOS, there are lots of strong assumptions inside R packages (especially for Java and Fortran).

Upvotes: 1

Related Questions