9

I am trying to install the package glmnet. I get this error:

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

I installed homebrew. Then fortran through gcc to get this far. I have found many help links that say similar things like this:

you will need to change your compile statements in ~/.R/Makevars to gcc using:

VER=-5.3.0 
CC=gcc$(VER)
CXX=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/5.3.0/lib/gcc/5

I can't find ~/.R/Makevars on my Mac!! I have macOS Catalina 10.15.1.

I have found two Makevars files. They are linked to Rcpp and have nothing at all similar to the code listed above.

Sorry for this seemingly basic questions, but two hours in and I can't find anything related to ~/.R/Makevars.

Here is what the one file I did find states:

## With R 3.1.0 or later, you can uncomment the following line to tell R to 
## enable compilation with C++11 (where available)
##
## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider
## availability of the package we do not yet enforce this here.  It is however
## recommended for client packages to set it.
##
## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP
## support within Armadillo prefers / requires it
CXX_STD = CXX11

PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) 
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

But that was linked to RcppArmadillo.

I've read these (any many more) many times over:

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Kevin W.
  • 136
  • 1
  • 1
  • 5
  • 8
    Decompose it. First, `~` is `$HOME`. Next , `~/.R/` is a (optional) directory `.R` inside your home directory. Then, `~/.R/Makevars` is a filed called `Makevars` in the directory `.R` in your home directory. That file has to be created by you -- R does not ship with it, but documents its use. – Dirk Eddelbuettel Nov 11 '19 at 00:02
  • Dirk, Thanks for the reply. But I guess I'm not savvy enough to know exactly what that means still. What is my $HOME? My R 3.6 is stored on my computer at (my drive is called MacOS): MacOS/Library/Frameworks/R.framework/Version/3.6/. Which part is considered my $HOME? And am I making a new folder called /.R/? If so, in what folder would I place it? – Kevin W. Nov 11 '19 at 20:57
  • 2
    On Unix, `$HOME` is typically in `/home/yourusername`, _i.e._ `/home/edd` on my machines as I log in as `edd`. For you on macOS it _may be_ `/User/yourusername`. The key is `$HOME` abstracts that. Open the Terminal app and type `echo $HOME` followed by return and you should see. – Dirk Eddelbuettel Nov 11 '19 at 21:08
  • Thanks Dirk. So, I have `/Users/kevinwilliams` So for this situation, I should create a folder here called /.R/ and then add the text file called "Makevars" in that folder? – Kevin W. Nov 11 '19 at 21:16
  • Yep, exactly. And you should then see change in behaviour _i.e._ you can set compile and link flags for _all_ your R package builds -- irrespective of / along with the `src/Makevars` a package may have. – Dirk Eddelbuettel Nov 11 '19 at 21:24
  • Thanks Dirk! Working now I think. Learning experience for me for sure. Been a very, very long time since I've worked at the command line. Thanks for spelling that out for me. – Kevin W. Nov 12 '19 at 01:25
  • 1
    Excellent news that you got it working. Now, as always, on to the next problem and headache ;-) – Dirk Eddelbuettel Nov 12 '19 at 01:26
  • It seems to be called Makevars.win in Windows? – Simon Woodward Mar 15 '22 at 21:08
  • Where is this Makevars file on Windows? – Ramesh Kadambi Sep 13 '22 at 09:27

1 Answers1

2
  1. Create folder /Users/YOURNAME/.R
  2. Create text file /Users/YOURNAME/.R/Makevars
  3. Put this into that file:
FC      = /usr/local/opt/gcc/bin/gfortran
F77     = /usr/local/opt/gcc/bin/gfortran
FLIBS   = -L/usr/local/opt/gcc/lib
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214