我使用的是配备 Apple M1 芯片、运行 macOS 11.6 Big Sur 的 MacBook Air。我正在使用 R 4.1.1。我安装了适用于 Apple M1 的 Xtools 和 gfortran:
\nmarkwhite@marks-air ~ % which xcode-select\n/usr/bin/xcode-select\nmarkwhite@marks-air ~ % which gfortran\n/usr/local/bin/gfortran\nRun Code Online (Sandbox Code Playgroud)\n我能够成功安装并运行 R\xe2\x80\x94,但是安装一些软件包给我带来了麻烦:
\n> install.packages("mvtnorm")\n\n There is a binary version available but the source version is later:\n binary source needs_compilation\nmvtnorm 1.1-2 1.1-3 TRUE\n\nDo you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes\ninstalling the source package \xe2\x80\x98mvtnorm\xe2\x80\x99\n\ntrying URL \'https://cran.rstudio.com/src/contrib/mvtnorm_1.1-3.tar.gz\'\nContent type \'application/x-gzip\' length 166421 bytes (162 …Run Code Online (Sandbox Code Playgroud) 这个问题与其他一些问题有关,比如RccpArmadillo或element-wise-multiplication.
但是,我的设置是这样的,我不知道我有什么编辑/ simlink使Rccp运行而不给我警告.
我使用最新的R版本在Mac 10.9(小牛队)上.
在一开始,尝试从RCCpvsR得到的以下代码,我收到一个错误:
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)`
Run Code Online (Sandbox Code Playgroud)
然后,基于RccpArmadillo,我做了以下事情:
# Update FLIBS in ~/.R/Makevars
FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran
#Re-Install from source
install.packages(c("Rcpp","RcppArmadillo","inline"),type="source")
#Restart R
Run Code Online (Sandbox Code Playgroud)
这是因为我没有/usr/local/Cellar/gfortran/目录所以只是尝试了.事实上,我的所有libgfortran*文件都在这里(在macports目录下):
>ls /opt/local/lib/gcc48/libgfortran.*
/opt/local/lib/gcc48/libgfortran.3.dylib /opt/local/lib/gcc48/libgfortran.dylib
/opt/local/lib/gcc48/libgfortran.a /opt/local/lib/gcc48/libgfortran.spec
Run Code Online (Sandbox Code Playgroud)
在这里/opt/local/lib/gcc48/gcc/x86_64-apple-darwin13/4.8.3/libgfortranbegin.a,我没有任何gfortran文件.
然后我再次尝试了代码RccpvsR,令人惊讶的是,它工作了!除了我得到警告的事实:
ld: warning: directory not found for option '-L/usr/local/Cellar/gfortran/4.8.2/gfortran'
Run Code Online (Sandbox Code Playgroud)
因为它当然不存在,但是该代码创建的函数cosineRcpp运行没有问题.
因此,所有这些,要问是否有人知道我是否必须将libgfortran文件链接 …
我在新笔记本电脑(在 MacOS Catalina 上运行)上下载了旧的存储库,并尝试运行 R 脚本。
\n该存储库有一个 renv 锁定文件 - 这意味着,我应该能够按原样恢复所有依赖项。
\n但当我运行该renv::restore()命令时,出现以下错误消息:
Installing pbapply [1.4-3] ...\n OK [linked cache]\nInstalling mvtnorm [1.1-2] ...\n FAILED\nError installing package \'mvtnorm\':\n===================================\n\n* installing to library \xe2\x80\x98~/renv/staging/2\xe2\x80\x99\n* installing *source* package \xe2\x80\x98mvtnorm\xe2\x80\x99 ...\n** package \xe2\x80\x98mvtnorm\xe2\x80\x99 successfully unpacked and MD5 sums checked\n** libs\nclang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c C_FORTRAN_interface.c -o C_FORTRAN_interface.o\nclang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c miwa.c -o miwa.o\ngfortran -fPIC -g -O2 -c mvt.f -o mvt.o\nclang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装包 glmnet。我收到此错误:
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
Run Code Online (Sandbox Code Playgroud)
我安装了自制软件。然后通过 gcc fortran 达到这个目的。我找到了很多帮助链接,上面写着类似的东西:
“您需要使用以下命令将 ~/.R/Makevars/ 中的编译语句更改为 gcc:
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
Run Code Online (Sandbox Code Playgroud)
我在 Mac 上找不到 ~/.R/Makevars/ !!我有 macOS Catalina 10.15.1。
我找到了两个 Makevars 文件。它们与 Rcpp 相关联,并且与上面列出的代码完全不同。
抱歉,这个看似基本的问题,但两个小时后,我找不到与 ~/.R/Makevars/ 相关的任何内容
这是我找到的一个文件的状态:
## With R 3.1.0 or later, you can uncomment the following line to tell R …Run Code Online (Sandbox Code Playgroud) 我在使用以下代码行从 CRAN 在 macOS 上安装 ape 包时遇到问题:install.packages("ape")。
我得到以下输出:
ld:警告:找不到选项“L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2”的目录 ld:找不到 -lgfortran clang 的库:错误:链接器命令失败,退出代码1(使用-v查看调用)
我尝试通过在终端中使用以下代码安装 Xcode 来解决该问题:xcode-select--install。这并没有什么帮助。