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

OS X 12.4+XCode13.4编译AI-Feynman报!tapi-tbd错误解决方案

问题说明
  • 运行环境:OS X 12.4 操作系统、XCode 13.4 开发环境
  • 编译目标:AI-Feynman 开源项目
  • 失败阶段:Fortran扩展模块链接阶段
  • 核心报错:链接器ld无法识别x86_64架构下YAML格式tbd文件中的!tapi-tbd类型,编译流程终止

编译阶段执行的命令及完整报错如下:

/Users/davidlaxer/anaconda3/envs/AI-Feynman/bin/x86_64-apple-darwin13.4.0-gfortran -Wall -g -arch x86_64 -Wall -g -undefined dynamic_lookup -bundle build/temp.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/aifeynman/_symbolic_regress1module.o build/temp.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/aifeynman/fortranobject.o build/temp.macosx-10.9-x86_64-3.9/aifeynman/symbolic_regress1.o build/temp.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/aifeynman/_symbolic_regress1-f2pywrappers.o -L/Users/davidlaxer/anaconda3/envs/AI-Feynman/bin/../lib/gcc/x86_64-apple-darwin11.4.2/4.8.5 -L/Users/davidlaxer/anaconda3/envs/AI-Feynman/bin/../lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/../../.. -L/Users/davidlaxer/anaconda3/envs/AI-Feynman/bin/../lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/../../.. -lgfortran -o aifeynman/_symbolic_regress1.cpython-39-darwin.so
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
error: Command "/Users/davidlaxer/anaconda3/envs/AI-Feynman/bin/x86_64-apple-darwin13.4.0-gfortran -Wall -g -arch x86_64 -Wall -g -undefined dynamic_lookup -bundle build/temp.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/aifeynman/_symbolic_regress1module.o build/temp.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/aifeynman/fortranobject.o build/temp.macosx-10.9-x86_64-3.9/aifeynman/symbolic_regress1.o build/temp.macosx-10.9-x86_64-3.9/build/src.macosx-10.9-x86_64-3.9/aifeynman/_symbolic_regress1-f2pywrappers.o -L/Users/davidlaxer/anaconda3/envs/AI-Feynman/bin/../lib/gcc/x86_64-apple-darwin11.4.2/4.8.5 -L/Users/davidlaxer/anaconda3/envs/AI-Feynman/bin/../lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/../../.. -L/Users/davidlaxer/anaconda3/envs/AI-Feynman/bin/../lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/../../.. -lgfortran -o aifeynman/_symbolic_regress1.cpython-39-darwin.so" failed with exit status 1
故障原因

Anaconda虚拟环境内预装的gfortran 4.8.5是适配2013年OS X 10.9系统的老旧版本,配套的ld链接器、tapi库解析工具版本过低,无法识别XCode 13.4自带MacOS SDK中采用新格式的.tbd动态库存根文件,最终触发解析错误。

解决步骤

按顺序执行以下操作即可修复编译问题:

  1. 进入对应AI-Feynman的conda虚拟环境,替换老旧的编译工具链为适配新系统的版本,执行命令:
    conda activate AI-Feynman
    conda install -c conda-forge gfortran cctools ld64 -y
    
  2. 配置编译环境变量,强制编译时使用系统原生的新版链接器、指定正确的SDK路径,执行命令:
    export CC=/usr/bin/clang
    export CXX=/usr/bin/clang++
    export LD=/usr/bin/ld
    export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
    export LDFLAGS="-Wl,-syslibroot,${SDKROOT}"
    
  3. 清理之前编译失败产生的临时缓存文件,重新执行编译安装:
    rm -rf build/
    python setup.py install
    

若执行完上述步骤仍有报错,可直接通过Homebrew安装新版gcc套件,编译前将PATH环境变量中Homebrew的bin目录优先级调至conda路径之前,优先调用brew安装的新版gfortran即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.03 00:47:06