solana-labs / example-helloworld

Hello world on Solana
MIT License
900 stars 864 forks source link

could not compile `getrandom` due to 2 previous errors #571

Closed dayofthetech closed 1 year ago

dayofthetech commented 1 year ago

Following the steps from this video https://www.youtube.com/watch?v=P22z9n1np9A&list=PL53JxaGwWUqCr3xm4qvqbgpJ4Xbs4lCs7&index=4

When running npm run build:program-rust the compiling goes smoothly until it reaches this point

Compiling getrandom v0.2.3
   Compiling wasm-bindgen-backend v0.2.79
   Compiling synstructure v0.12.4
   Compiling borsh-schema-derive-internal v0.9.3
   Compiling borsh-derive-internal v0.9.3
   Compiling thiserror-impl v1.0.30
error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> src/lib.rs:224:9
    |
224 | /         compile_error!("target is not supported, for more information see: \
225 | |                         https://docs.rs/getrandom/#unsupported-targets");
    | |________________________________________________________________________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> src/lib.rs:246:5
    |
246 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `getrandom` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

After checking doc I saw that getrandom has to be added to the toml file which I did

[dependencies]
borsh = "0.9.3"
borsh-derive = "0.9.1"
solana-program = "~1.10.35"
getrandom = { version = "0.2", features = ["js"] }

But still not working, unable to create .so file

joncinque commented 1 year ago

Hi there, we don't use GitHub for developer support, and encourage you to ask your question on the Solana Stack Exchange https://solana.stackexchange.com/ or some other developer support forum.