You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac M3 Sonoma14.5下RcppArmadillo提示gfortran未找到如何解决?

Rcpp/RcppArmadillo提示gfortran未找到但系统已安装的解决方法

问题描述

运行sourceCpp()执行Rcpp程序时触发链接错误:

ld: warning: search path '/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0' not found
ld: library 'gfortran' not found

但系统已安装GNU Fortran 13.2.0,验证输出:

GNU Fortran (GCC) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

中间排查步骤

  • 2025年3月21日:通过Homebrew重装R和RStudio,Rcpp可正常运行,但RcppArmadillo仍报相同的gfortran未找到错误。

最终解决方案

2025年3月22日完成以下操作后问题解决:

  1. 在R控制台执行命令获取gfortran的实际路径:
    system("which gfortran")
    
  2. 打开R的配置文件:
    file.edit(file.path(R.home("etc"), "Makeconf"))
    
  3. 在打开的文件中找到FC和FLIBS配置项,将其值修改为步骤1中得到的gfortran路径,保存文件后重启R即可。

内容的提问来源于stack exchange,提问作者FAM

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 20:03:14