Mac OS X R 错误“ld:警告:找不到选项的目录"

编程入门 行业动态 更新时间:2024-10-21 14:22:39
本文介绍了Mac OS X R 错误“ld:警告:找不到选项的目录"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试从源代码安装 R 包,但出现错误:

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

* installing *source* package ‘mclust’ ... ** package ‘mclust’ successfully unpacked and MD5 sums checked ** libs gfortran-4.8 -fPIC -g -O2 -c mclust.f -o mclust.o gfortran-4.8 -fPIC -g -O2 -c mclustaddson.f -o mclustaddson.o clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o mclust.so mclust.o mclustaddson.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2' ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2' ld: library not found for -lquadmath clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [mclust.so] Error 1 ERROR: compilation failed for package ‘mclust’ * removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/mclust’ Warning in install.packages : installation of package ‘mclust’ had non-zero exit status

我没有 /usr/local/lib/gcc/x86_64-apple-darwin13.0.0,所以找不到它是有道理的.我有 /usr/local/lib/gcc/i686-apple-darwin11 和 /usr/local/lib/gcc/4.8 (指向 Homebrew 安装的符号链接).x86_64-apple-darwin13.0.0 从哪里获得?

I don't have /usr/local/lib/gcc/x86_64-apple-darwin13.0.0, so it makes sense that it can't be found. I have /usr/local/lib/gcc/i686-apple-darwin11 and /usr/local/lib/gcc/4.8 (symlink to Homebrew installation). Where is it getting x86_64-apple-darwin13.0.0 from?

网上有很多类似错误的参考资料.但是都和Xcode编译有关,通过更新工程设置解决,这里不适用.

There are a lot of references to a similar error online. However, all of them are related to compiling in Xcode and resolved by updating project settings, which is not applicable here.

推荐答案

需要修改~/.R/Makevars文件.有关更多信息,请参阅:cran.r-project/doc/manuals/r-release/R-admin.html#OS-X-packages

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

或者,@kevin-ushey 在 Rcpp警告:找不到选项'-L/usr/local/Cellar/gfortran/4.8.2/gfortran'的目录";.

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'".

发生的事情是您的代码没有在 gcc 下运行,而是被转发到 clang

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

您需要将 ~/.R/Makevars/ 中的编译语句更改为 gcc 使用:

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

这假设您已经通过自制软件安装了 gcc :

This assumes you have already installed gcc via homebrew under:

brew install gcc

(gfortran 现在在 brew 中带有 gcc)

(gfortran ships with gcc in brew now)

更多推荐

Mac OS X R 错误“ld:警告:找不到选项的目录"

本文发布于:2023-07-04 17:12:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1026910.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   选项   错误   目录   Mac

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!