Question: Issue when trying to install 'RcppArmadillo': /usr/bin/ld: cannot find -lgfortran
gravatar for Wet&DryImmunology
3.6 years ago by
Wet&DryImmunology220 wrote:

Hi my primary goal is to use DiffBind to analyze my ChIPseq data.

Following the suggestion that I might need to update my DiffBind I tried to install a new version of it.

By the checking the dependency of DiffBind I guess that the previous installation automatically install an old version of DiffBind because my R did not meet the requirement of current version of DiffBind.

But I was using the R under the root directory, for which I could not do much about it. So I decided install a newer version of R under my own directory. and I managed to do that.

Then I tried to install the current version of DiffBind, I got the error

ERROR: compilation failed for package ‘RcppArmadillo’

It turned out the dependency lib "RcppArmadillo" require a more up-to-date compiler, again, I was using the gcc compiler under the root directory, so I install a new version of gcc under my own directory.

    $ gcc --version

    gcc (GCC) 6.1.0

    Copyright (C) 2016 Free Software Foundation, Inc.

    This is free software; see the source for copying conditions.  There is NO


    $ which gcc


After that I tried to install the DiffBind (RcppArmadillo) again, but met another error:

* installing *source* package ‘RcppArmadillo’ ...
**   package 'RcppArmadillo' successfully unpacked and MD5 sums checked 
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking whether g++ version is sufficient... (6.1.0) yes
checking LAPACK_LIBS... fallback LAPACK from R 3.3.0 or later used
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloLapack.h
** libs
g++ -I/$HOME/Programme/R-3.3.1/lib64/R/include -DNDEBUG  -I//$HOME/Programme/zlib-1.2.11/include -I//$HOME/Programme/bzip2-1.0.6/include -I//$HOME/Programme/xz-5.2.3/include -I//$HOME/Programme/pcre-8.40/include -I//$HOME/Programme/curl-7.52.1/include -I"/$HOME/Programme/R-3.3.1/lib64/R/library/Rcpp/include"  -I../inst/include -fpic  -g -O2  -c RcppArmadillo.cpp -o RcppArmadillo.o
g++ -I/$HOME/Programme/R-3.3.1/lib64/R/include -DNDEBUG  -I//$HOME/Programme/zlib-1.2.11/include -I//$HOME/Programme/bzip2-1.0.6/include -I//$HOME/Programme/xz-5.2.3/include -I//$HOME/Programme/pcre-8.40/include -I//$HOME/Programme/curl-7.52.1/include -I"/$HOME/Programme/R-3.3.1/lib64/R/library/Rcpp/include"  -I../inst/include -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++ -I/$HOME/Programme/R-3.3.1/lib64/R/include -DNDEBUG  -I//$HOME/Programme/zlib-1.2.11/include -I//$HOME/Programme/bzip2-1.0.6/include -I//$HOME/Programme/xz-5.2.3/include -I//$HOME/Programme/pcre-8.40/include -I//$HOME/Programme/curl-7.52.1/include -I"/$HOME/Programme/R-3.3.1/lib64/R/library/Rcpp/include"  -I../inst/include -fpic  -g -O2  -c fastLm.cpp -o fastLm.o
g++ -shared -L/$HOME/Programme/R-3.3.1/lib64/R/lib -L//$HOME/Programme/zlib-1.2.11/lib -L//$HOME/Programme/bzip2-1.0.6/lib -L//$HOME/Programme/xz-5.2.3/lib -L//$HOME/Programme/pcre-8.40/lib -L//$HOME/Programme/curl-7.52.1/lib -o RcppArmadillo.o RcppExports.o fastLm.o -L/$HOME/Programme/R-3.3.1/lib64/R/lib -lRlapack -L/$HOME/Programme/R-3.3.1/lib64/R/lib -lRblas -lgfortran -lm -L/$HOME/Programme/R-3.3.1/lib64/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status**

it turned out that "gfortran" could not be found. but when I checked existence of "gfortran" it exist:

$ which gfortran


$ gfortran --version 

GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)

Copyright (C) 2010 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.

You may redistribute copies of GNU Fortran

under the terms of the GNU General Public License.

For more information about these matters, see the file named COPYING

So I assumed that gcc could not find gfortran, which is under the root directory, how could I solve the problem? Or could it be possible that the mismatch between the gcc and gfortran is the problem? if that is the case, what could be done to circumvent it? Anyone has any idea please kindly let me know. Thanks a lot in advance.


> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.7 (Santiago)

 [1] LC_CTYPE=ja_JP.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=ja_JP.UTF-8        LC_COLLATE=ja_JP.UTF-8    
 [7] LC_PAPER=ja_JP.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
chip-seq software error • 2.1k views
ADD COMMENTlink modified 3.6 years ago by Biostar ♦♦ 20 • written 3.6 years ago by Wet&DryImmunology220

Check the version numbers. You're using gcc 6.1 but the gfortran you have is from gcc 4.7. If you compiled gcc from source, you have to make sure you enabled the fortran compiler. You may also have to make sure that its C standard library is used by setting LD_LIBRARY_PATH. See for example here.

ADD REPLYlink written 3.6 years ago by Jean-Karim Heriche23k

@Jean-Karim Heriche. Yes, I am recompiling gcc from the source with fortran enabled. The "make" command takes very long time to finish... but I guess it would work out. Really appreciate your suggestion.

ADD REPLYlink written 3.6 years ago by Wet&DryImmunology220
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1120 users visited in the last hour