最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

cargo - How to build solana contracts? - Stack Overflow

programmeradmin4浏览0评论

I am just trying to set up a development environment. I created a virtual machine with a clean install of Ubuntu 24.04.1 then followed the install instructions solana and any other site with instructions I can find. I have tried multiple ways and always end up running in to errors with instructions that don't seem to work.

solana-cli 2.2.3 (src:0b37b8fd; feat:3294202862, client:Agave) cargo 1.85.1 (d73d2caf9 2024-12-31)

The best I have gotten is with

Cargo.toml:

cargo-features = ["edition2024"]


[package]
name = "solana_hello"
version = "0.1.0"
edition = "2024"

[dependencies]
solana-program = "=2.1.16"

[lib]
name = "solana_hello"
crate-type = ["cdylib", "lib"]

src/lib.rs:

use solana_program::{
    account_info::AccountInfo,
    entrypoint,
    entrypoint::ProgramResult,
    pubkey::Pubkey,
    msg,
};

// Declare the program's entrypoint
entrypoint!(process_instruction);

// Program entrypoint implementation
pub fn process_instruction(
    _program_id: &Pubkey,
    _accounts: &[AccountInfo],
    _instruction_data: &[u8],
) -> ProgramResult {
    // Log a message to the blockchain
    msg!("Hello, world from Solana program!");
    Ok(())
}

absolute bear bone test. When I run

cargo build-sbf

It gives the output:

info: uninstalling toolchain 'solana' info: toolchain 'solana' uninstalled error: rustc 1.79.0-dev is not supported by the following package:

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 to install a newer version. [email protected] requires rustc 1.84 Either upgrade rustc or select compatible dependency versions with cargo update <name>@<current-ver> --precise <compatible-ver> where <compatible-ver> is the latest version supporting rustc 1.79.0-dev

solana-install update comes back command not found and I have tried everything in the doc mentioned in the error code. Any suggestions on what I can try?

I am just trying to set up a development environment. I created a virtual machine with a clean install of Ubuntu 24.04.1 then followed the install instructions solana and any other site with instructions I can find. I have tried multiple ways and always end up running in to errors with instructions that don't seem to work.

solana-cli 2.2.3 (src:0b37b8fd; feat:3294202862, client:Agave) cargo 1.85.1 (d73d2caf9 2024-12-31)

The best I have gotten is with

Cargo.toml:

cargo-features = ["edition2024"]


[package]
name = "solana_hello"
version = "0.1.0"
edition = "2024"

[dependencies]
solana-program = "=2.1.16"

[lib]
name = "solana_hello"
crate-type = ["cdylib", "lib"]

src/lib.rs:

use solana_program::{
    account_info::AccountInfo,
    entrypoint,
    entrypoint::ProgramResult,
    pubkey::Pubkey,
    msg,
};

// Declare the program's entrypoint
entrypoint!(process_instruction);

// Program entrypoint implementation
pub fn process_instruction(
    _program_id: &Pubkey,
    _accounts: &[AccountInfo],
    _instruction_data: &[u8],
) -> ProgramResult {
    // Log a message to the blockchain
    msg!("Hello, world from Solana program!");
    Ok(())
}

absolute bear bone test. When I run

cargo build-sbf

It gives the output:

info: uninstalling toolchain 'solana' info: toolchain 'solana' uninstalled error: rustc 1.79.0-dev is not supported by the following package:

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/cli/install to install a newer version. [email protected] requires rustc 1.84 Either upgrade rustc or select compatible dependency versions with cargo update <name>@<current-ver> --precise <compatible-ver> where <compatible-ver> is the latest version supporting rustc 1.79.0-dev

solana-install update comes back command not found and I have tried everything in the doc mentioned in the error code. Any suggestions on what I can try?

Share Improve this question asked Mar 23 at 22:03 Matthew CornelisseMatthew Cornelisse 1,04310 silver badges16 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I managed to get it to work by downgrading 2 of the libraries it was trying to use. New Cargo.toml



[package]
name = "solana_hello"
version = "0.1.0"
edition = "2021"
[dependencies]
bytemuck = { version = "=1.22.0", default-features = false }
bytemuck_derive = "=1.7.1"
solana-program = "=1.18.13"
[lib]
name = "solana_hello"
crate-type = ["cdylib", "lib"]
发布评论

评论列表(0)

  1. 暂无评论