使用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工具链的动态库包含当前系统不支持的加载命令导致,可通过以下步骤修复:
- 移除损坏的Solana工具链:
rustup toolchain remove solana - 重新安装对应版本的Solana工具链(匹配项目使用的v1.37.0版本):
solana-install init 1.37.0 - 清理Cargo缓存,避免依赖残留:
rm -rf ~/.cargo/registry ~/.cargo/git - 再次执行构建命令:
anchor build
内容的提问来源于stack exchange,提问作者Zoro
相关产品推荐
相关产品推荐

