解决编译solana程序 rustc版本号过低的问题
本方主要介绍在编译solana程序时,提示 rustc 版本号过低无法编译通过的问题。
问题描述
在参考官方教程 https://github.com/solana-developers/program-examples/tree/main/basics/favorites/native 在本地执行命令
➜ native git:(main) ✗ cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so
报错
➜ native git:(main) ✗ cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so
error: package `solana-program v2.1.7` cannot be built because it requires rustc 1.79.0 or newer, while the currently active rustc version is 1.75.0-dev
Note that this is the rustc version that ships with Solana tools and not your system's rustc version. Use `solana-install update` or head over to https://docs.solanalabs.com/cli/install to install a newer version.
Either upgrade to rustc 1.79.0 or newer, or use
cargo update [email protected] --precise ver
where `ver` is the latest version of `solana-program` supporting rustc 1.75.0-dev
翻译过来就是使用的 rustc 版本号过低,至少需要1.9.0 或更高才可以,这里的rustc版本与并非本地安装的rustc版本号。






