安装R包“ld:警告:未找到选项的目录“

ncecgwcz  于 2023-06-19  发布在  其他
关注(0)|答案(3)|浏览(134)

我正在尝试在R中安装gradientForest包,方法是使用

install.packages("gradientForest", repos="http://R-Forge.R-project.org")

我得到这个错误

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

我已经试过this thread和这个线程的答案。
根据这些线程,我已经安装了gcc使用

brew install gcc

我的Makevar看起来像

## With Rcpp 0.11.0 and later, we no longer need to set PKG_LIBS as there is
## no user-facing library. The include path to headers is already set by R.
#PKG_LIBS = 

## With R 3.1.0 or later, you can uncomment the following line to tell R to 
## enable compilation with C++11 (or even C++14) where available
CXX_STD = CXX17

VER=-9
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`gfortran -print-file-name=libgfortran.dylib | xargs dirname`

但不幸的是,这并不能改变我所犯的错误。我的R版本是3.6.1,我在MacOS Catalina 上。
如果有人能帮助我,我将非常感激。谢谢

70gysomp

70gysomp1#

得到了相同的编译错误。手动重新安装Clang和GFortran解决了我的问题。我使用的指令:R COMPILER TOOLS FOR RCPP ON MACOS
(on Catalina 10.15.3; R 3.6.2; RStudio 1.2.5)

u91tlkcl

u91tlkcl2#

下面是R官方文档中关于如何在Mac上安装R的片段,以及相关错误:

CC = /usr/local/clang7/bin/clang
CXX = /usr/local/clang7/bin/clang++
CXX11 = $CXX
CXX14 = $CXX
CXX17 = $CXX
CFLAGS = -g -O2 -Wall -pedantic -Wconversion -Wno-sign-conversion
CXXFLAGS = -g -O2 -Wall -pedantic -Wconversion -Wno-sign-conversion
CXX11FLAGS = $CXXFLAGS
CXX14FLAGS = $CXXFLAGS
CXX17FLAGS = $CXXFLAGS
and gfortran by (El Capitan)

FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0
  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
or (Sierra or High Sierra)

FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0
  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
or (Mojave or later)

FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0
  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
(with lines broken here for legibility).

If using the C/C++ compilers from the Command Line Tools (which do not have OpenMP support) one will need to include

SHLIB_OPENMP_CFLAGS =
SHLIB_OPENMP_CXXFLAGS =

欲了解更多信息,请访问以下链接6.3.2
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html
这可能对你有帮助

5vf7fwbs

5vf7fwbs3#

更新/Library/Frameworks/R.framework/Resources/etc/Makeconf中的FLIBS变量为我解决了这个问题
https://medium.com/biosyntax/following-up-library-dependency-when-compiling-r-packages-89f191b9f227

相关问题