3

Attempting to 'anchor build' a project and running into errors with the #[program] macro. Unsure exactly what could be causing these. Tried reading the compiler error index but it didnt seem to help in this context.

Errors:

    error[E0432]: unresolved import `crate`
  --> programs/solfund/src/lib.rs:10:1
   |
10 | #[program]
   | ^^^^^^^^^^ could not find `__client_accounts_contributor` in the crate root
   |
   = note: this error originates in the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)

error: the `#[global_allocator]` in this crate conflicts with global allocator in: solend_program

error[E0637]: `&` without an explicit lifetime name cannot be used here
  --> programs/solfund/src/lib.rs:10:1
   |
10 | #[program]
   | ^ explicit lifetime name needed here
   |
   = note: this error originates in the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0106]: missing lifetime specifier
  --> programs/solfund/src/lib.rs:10:1
   |
10 | #[program]
   | ^ expected named lifetime parameter
   |
   = note: this error originates in the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider introducing a named lifetime parameter
   |
10 ~ #<'a>[program]
11 | pub mod solfund {
12 |     use super::*;
13 | 
14 |     pub fn create_fundraiser(
15 |         ctx: Context<CreateFundraiser>,
 ...

Some errors have detailed explanations: E0106, E0432, E0637.
For more information about an error, try `rustc --explain E0106`.

Any ideas?

3 Answers 3

1

Try adding solend-program = { version = "the-version", features = ["no-entrypoint"] } in your Cargo.toml file. Also, you might want to check any & you have around in your code especially if it's a string. You should use String rather than &str. I can't deduce much without looking at the code.

1

I'm facing the same issue. My error is

could not find __client_accounts_games in the crate root

So I'm beginning to think anchor expects you to export all certain things from the lib.rs file. For this particular error, it seems like you need to define the accounts for your program in the lib.rs file.

I worked around mine by simply pub use my_mod::*;'ing in the lib.rs file. Here, my_mod is the name of my module containing the required accounts. That fixed it for me

0

Just import __client_accounts_games from games mod. Anchor creates specific declarations I don't know what for, but looks like it needs it to work properly

pub mod instructions;
    
use anchor_lang::prelude::*;
use instructions::init_instruction::{init_instruction, InitVote, __client_accounts_init_vote};
use instructions::vote_instruction::{vote_instruction, Vote, VoteType, __client_accounts_vote};

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.