2

I'm new to solana. When i run solana program deploy target/release/libsol_contract.so it shows ELF error: Failed to parse

Lib.rs:

use anchor_lang::prelude::*;

declare_id!("11111111111111111111111111111111");

#[program]
mod hello_world {
    use super::*;
    pub fn say_hello(_ctx: Context<SayHello>) -> Result<()> {
        msg!("Hello World!");       
        Ok(())
    }
}

#[derive(Accounts)]
pub struct SayHello {}

When I run solana program deploy target/release/libsol_contract.so I get:

Error: ELF error: ELF error: Failed to parse ELF file: Section or symbol name .note.gnu.build- is longer than 16 bytes
7
  • Please provide full error and your code Commented Jan 21 at 13:36
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jan 21 at 13:36
  • Akhtar can you check now, I have included the contract and the error. Commented Jan 22 at 2:43
  • Maybe id can’t be 11111111111111111111111111111111
    – wei1769
    Commented Jan 22 at 2:47
  • @wei1769 what should be used in the place of id? Commented Jan 22 at 2:49

2 Answers 2

1

When using the anchor framework you should use the anchor deploy command. If it's the first time building the project you should run the anchor build command. This will compile your project and install all the necessary dependencies.

Note: It's important to consider how you've installed Anchor. I recommend installing using the Anchor Version Manager(AVM), this will significantly reduce the likelihood of encountering dependency-related issues.

0

The program’s build command is not cargo build —-release it should be cargo build-sbf.

2
  • I have deployed the contract, how to call the function from the cli ? Commented Jan 22 at 4:57
  • You need to write a test file.
    – wei1769
    Commented Jan 22 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.