简体   繁体   English

尝试安装 R 包时出现“ld:警告:未找到目录”

[英]"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:我目前在运行 El Cap 10.11.6 的 Mac 上尝试在 R Studio 中安装“robustbase”包,但遇到以下错误:

    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.我环顾四周以找到可能的解决方案,并在此线程中看到我可能需要修改 R/makevars 文件。

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.这超出了我对 R 和代码的基本知识,因此感谢任何帮助。

Let me know if any additional information would be of help!如果任何其他信息有帮助,请告诉我!

You seem to be running an outdated version of R .您似乎正在运行R的过时版本。 You should install the latest version.您应该安装最新版本。 What follows is only valid for the latest version of R .以下内容仅对最新版本的R有效。

You don't seem to have the Fortran compiler installed.您似乎没有安装 Fortran 编译器。 You can get it from CRAN on this page tools .您可以在此页面工具上从 CRAN 获取它。 You might also need to install the clang6 compiler available on the same page.您可能还需要安装同一页面上可用的clang6编译器。

If you do that you should add this如果你这样做,你应该添加这个

/usr/local/clang6/bin 

to the start of your PATH.到 PATH 的开头。 You should check that /usr/local/bin is in your path to make the gfortran compiler accessible.您应该检查/usr/local/bin是否在您的路径中,以使 gfortran 编译器可访问。

You should also add these lines to your ~/.R/Makevars .您还应该将这些行添加到您的~/.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' .在 macOS 15 Catalina 中,我收到了类似的错误: 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.那是因为我从另一个安装中复制粘贴了.R/Makevars

The fix for my macOS Catalina I used this Makevars configuration:我使用此 Makevars 配置修复了我的 macOS Catalina:

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.有了这个Makevars我已经能够从源代码来构建这些R封装: data.tablesfdevtoolsRcppArmadillopsychtmvnsimgower ,和其他许多人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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