Mac OS X R error “ld: warning: directory not found for option”

前端 未结 7 1415
梦毁少年i
梦毁少年i 2020-12-01 04:38

I am trying to install an R package from source, but getting an error:

* installing *source* package ‘mclust’ ...
** package ‘mclust’ successfully unpacked a         


        
相关标签:
7条回答
  • 2020-12-01 05:14

    Incorporating previous solutions with additional help from the comments, the following solution has worked for me on Mac OS X High Sierra.

    Create/edit ~/.R/Makevars with the following contents:

    VER=-8
    CC=gcc$(VER)
    CXX=g++$(VER)
    CXX11=g++$(VER)
    CXX14=g++$(VER)
    CXX17=g++$(VER)
    CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
    CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
    FLIBS=-L/usr/local/Cellar/gcc/8.2.0/lib/gcc/8
    

    Note, I am using homebrew and have gcc version 8.2.0 installed.

    0 讨论(0)
  • 2020-12-01 05:15

    From http://thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error/ you can fix this by downloading the optional gfortran libraries from http://r.research.att.com/libs/ and extracting them. To do this on the command line

    curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
    sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /
    
    0 讨论(0)
  • 2020-12-01 05:21

    I'm working on MacOS Mojave (10.14.5) and on R 4.0.0. The problem here is that "CRAN R 4.0.0 builds and higher no longer use any custom compilers" (see here), so the Makevars solution does not appear to work anymore.

    The solution for me was to download and install the GNU Fortran compiler from the official R-Project website. Note that you will also need Xcode and Xcode command-line tools.

    After running the installer with default settings, compilation of gfortran code worked without problems.

    0 讨论(0)
  • 2020-12-01 05:23

    I am having Mac OS Catalina and in my case installation of Homebrew, the newest gcc and Gfortran 8.2.0 solved the issue.

    0 讨论(0)
  • 2020-12-01 05:27

    You need to modify the ~/.R/Makevars file. For a greater overview of this see: https://cran.r-project.org/doc/manuals/r-release/R-admin.html#OS-X-packages

    Alternatively, this has been answered before in a bit more depth by @kevin-ushey in Rcpp warning: "directory not found for option '-L/usr/local/Cellar/gfortran/4.8.2/gfortran'".

    What is happening is your code is not being run under gcc instead it is being forwarded to clang

    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
    

    This assumes you have already installed gcc via homebrew under:

    brew install gcc
    

    (gfortran ships with gcc in brew now)

    0 讨论(0)
  • 2020-12-01 05:32

    The solution was to re-install problematic packages with Homebrew.

    $ brew uninstall --ignore-dependencies --force openssl
    $ brew install openssl
    
    $ brew uninstall --ignore-dependencies --force readline  
    $ brew install readline
    
    0 讨论(0)
提交回复
热议问题