Komal Rathi
Komal Rathi

Reputation: 4274

R package installation: ld: warning: directory not found for option '-L/usr/local/gfortran/lib'

I am trying to install an R package from source:

igraph

Here is my command:

install.packages('igraph_1.2.4.tar.gz', repos = NULL, type="source")

But I am getting the following error:

ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.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: *** [igraph.so] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/igraph’

Upvotes: 2

Views: 3377

Answers (1)

Komal Rathi
Komal Rathi

Reputation: 4274

After the fresh installation of R, I had to manually change the FLIBS variable in /Library/Frameworks/R.framework/Resources/etc/Makeconf to point to the gcc libraries.

Also, the post here helped: https://medium.com/biosyntax/following-up-library-dependency-when-compiling-r-packages-89f191b9f227

In detail the post suggests to change the following entries in Makeconf (make sure you use the correct version on your system):

# Use Homebrew gcc for OpenMP support
CC = gcc-8
# CC = clang # Original setting
...
# Use Homebrew gcc for OpenMP support
CXX = g++-8
# CXX = clang++ # Original setting
...
# Ask R to find the Homebrew copy of gcc
FLIBS = -L/usr/local/lib/gcc/8/gcc/x86_64-apple-darwin17.5.0/8.1.0 -L/usr/local/lib/gcc/8 -lgfortran -lquadmath -lm
# The original one
# FLIBS =  -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm

No restart of Rstudio is required after the changes are made.

Upvotes: 4

Related Questions