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

使用anchor build构建Solana项目时遇librustc_driver加载失败错误

Solana项目anchor build构建失败问题

错误信息

执行anchor build构建Solana项目时,出现以下错误:

error: process didn't exit successfully: `rustc -vV` (signal: 6, SIGABRT: process abort signal)
--- stderr
dyld: Library not loaded: @rpath/librustc_driver-c9ef59bea954d042.dylib
  Referenced from: /Users/zoro/.rustup/toolchains/solana/bin/rustc
  Reason: no suitable image found.  Did find:
    /Users/zoro/.cache/solana/v1.37/platform-tools/rust/bin/../lib/librustc_driver-c9ef59bea954d042.dylib: cannot load 'librustc_driver-c9ef59bea954d042.dylib' (load command 0x80000034 is unknown)
    /Users/zoro/.cache/solana/v1.37/platform-tools/rust/bin/../lib/librustc_driver-c9ef59bea954d042.dylib: stat() failed with errno=1
    /Users/zoro/.rustup/toolchains/solana/lib/librustc_driver-c9ef59bea954d042.dylib: cannot load 'librustc_driver-c9ef59bea954d042.dylib' (load command 0x80000034 is unknown)
    /Users/zoro/.rustup/toolchains/solana/lib/librustc_driver-c9ef59bea954d042.dylib: stat() failed with errno=1

已尝试无效方案

  • 执行rm -rf ~/.cache/solana/*清理Solana缓存后重新构建,问题依旧。

可行解决方案

该错误是由于Solana专用Rust工具链的动态库包含当前系统不支持的加载命令导致,可通过以下步骤修复:

  1. 移除损坏的Solana工具链:
    rustup toolchain remove solana
    
  2. 重新安装对应版本的Solana工具链(匹配项目使用的v1.37.0版本):
    solana-install init 1.37.0
    
  3. 清理Cargo缓存,避免依赖残留:
    rm -rf ~/.cargo/registry ~/.cargo/git
    
  4. 再次执行构建命令:
    anchor build
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 05:12:45