evan.oman
evan.oman

Reputation: 5562

Solana "Exec format error" When Building Hello World

I am trying to run Solana's example-hello-world on WSL 2 (have run it successfully on Linux before) and I am getting the following error:

> $ npm run build:program-rust

...

Finished release [optimized] target(s) in 19.64s
cargo-build-bpf child: /home/oman/.local/share/solana/install/releases/1.9.5/solana-release/bin/sdk/bpf/scripts/strip.sh /home/oman/dev/example-helloworld/src/program-rust/target/bpfel-unknown-unknown/release/helloworld.so /home/oman/dev/example-helloworld/dist/program/helloworld.so
/home/oman/.local/share/solana/install/releases/1.9.5/solana-release/bin/sdk/bpf/scripts/strip.sh: line 23: /home/oman/.local/share/solana/install/releases/1.9.5/solana-release/bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-objcopy: cannot execute binary file: Exec format error
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:program-rust: `cargo build-bpf --manifest-path=./src/program-rust/Cargo.toml --bpf-out-dir=dist/program`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build:program-rust script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/oman/.npm/_logs/2022-01-28T23_09_42_132Z-debug.log

Anything I am doing wrong?

Upvotes: 0

Views: 1112

Answers (1)

Jon C
Jon C

Reputation: 8402

This is probably an issue with the architecture of the WSL 2 installation. If it isn't x86_64, the bundled bpf tools will fail with exactly that error.

Can you make sure that your system architecture is correct by making sure that uname -m outputs x86_64? If not, be sure to install the correct version of WSL.

I'm no expert in this, but it's surprising that the compilation got past the build and failed at the symbol stripping. To be honest I would expect it to fail earlier with the architecture error, so it may turn out to be something else.

Upvotes: 1

Related Questions