简体   繁体   中英

"ld: Warning: directory not found" when attempting to install R package

I'm currently on a Mac running El Cap 10.11.6 attempting to install the 'robustbase' package in R Studio and am encountering the following 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: 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: *** [robustbase.so] Error 1
    ERROR: compilation failed for package ‘robustbase’
    * removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/robustbase’

I have looked around to find possible solutions and saw in this thread that I may be needing to modify the R/makevars file.

Is this the proper solution? If so, where do I modify this file, in my terminal? This is beyond my basic knowledge of R and code so any help is appreciated.

Let me know if any additional information would be of help!

You seem to be running an outdated version of R . You should install the latest version. What follows is only valid for the latest version of R .

You don't seem to have the Fortran compiler installed. You can get it from CRAN on this page tools . You might also need to install the clang6 compiler available on the same page.

If you do that you should add this

/usr/local/clang6/bin 

to the start of your PATH. You should check that /usr/local/bin is in your path to make the gfortran compiler accessible.

You should also add these lines to your ~/.R/Makevars .

CC=/usr/local/clang6/bin/clang
CXX=/usr/local/clang6/bin/clang++
LDFLAGS =-L/usr/local/clang6/lib

In macOS 15 Catalina, I was getting a similar error: ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0' . And that was because I copy-pasted .R/Makevars from another installation.

The fix for my macOS Catalina I used this Makevars configuration:

XCBASE=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
LLVMBASE=/usr/local/opt/llvm
GETTEXT=/usr/local/opt/gettext
GCCBASE=/usr/local/opt/gcc
LIBOMP=/usr/local/opt/libomp

# brew gcc: start
CC=$(LLVMBASE)/bin/clang
CXX=$(LLVMBASE)/bin/clang++
CXX11=$(LLVMBASE)/bin/clang++
CXX14=$(LLVMBASE)/bin/clang++
CXX17=$(LLVMBASE)/bin/clang++
CXX1X=$(LLVMBASE)/bin/clang++
# brew gcc: end

CPPFLAGS=-isystem "$(LLVMBASE)/include" -isysroot "$(XCBASE)"
LDFLAGS=-L"$(LLVMBASE)/lib" -L"$(GETTEXT)/lib" --sysroot="$(XCBASE)"

FC=$(GCCBASE)/bin/gfortran
F77=$(GCCBASE)/bin/gfortran

FLIBS=-L$(GCCBASE)/lib/gcc/9/ -lm

With this Makevars I have been able to build from source these R packages: data.table , sf , devtools , RcppArmadillo , psych , tmvnsim , gower , and many others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM