polkadot
polkadot copied to clipboard
Error on `cargo build` with polkadot version >= 0.9.26
I was doing some relay chain project and I followed the Substrate official tutorial on how to build a local relay chain. But I encountered the following errors while cargo build.
Logs:
$ cargo b -r
Updating git repository `https://github.com/paritytech/substrate`
Downloaded cfg-expr v0.10.3
Downloaded async-trait v0.1.57
Downloaded futures-core v0.3.23
Downloaded proc-macro2 v1.0.43
Downloaded ed25519-zebra v3.0.0
Downloaded futures-task v0.3.23
Downloaded futures-channel v0.3.23
Downloaded rpassword v7.0.0
Downloaded futures-sink v0.3.23
Downloaded futures-macro v0.3.23
Downloaded futures-util v0.3.23
Downloaded trie-db v0.24.0
Downloaded serde_json v1.0.85
Downloaded futures-io v0.3.23
Downloaded 14 crates (596.8 KB) in 2.19s
Compiling quote v1.0.20
Compiling proc-macro2 v1.0.43
Compiling unicode-ident v1.0.0
Compiling syn v1.0.98
Compiling version_check v0.9.3
...
Compiling polkadot-gossip-support v0.9.28 (/home/polkadot/substrate/relay-chain/polkadot/node/network/gossip-support)
Compiling polkadot-node-core-candidate-validation v0.9.28 (/home/polkadot/substrate/relay-chain/polkadot/node/core/candidate-validation)
Compiling polkadot-service v0.9.28 (/home/polkadot/substrate/relay-chain/polkadot/node/service)
Compiling polkadot v0.9.28 (/home/polkadot/substrate/relay-chain/polkadot)
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-m64" "/tmp/rustcc7lozz/symbols.o" ...
<some rlib>
...
"-Wl,--end-group" "/home/polkadot/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d1bd89f2a607e488.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lpthread" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/polkadot/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/polkadot/substrate/relay-chain/polkadot/target/release/deps/polkadot-087c28c0b59d766a" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs"
= note: /home/polkadot/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-69edc9ac8de4d39c.rlib(std-69edc9ac8de4d39c.std.2a45fe64-cgu.0.rcgu.o): In function `std::sys::unix::rand::imp::getrandom_fill_bytes::h4189d047809bb64a':
/rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys/unix/rand.rs:(.text._ZN3std3sys4unix4rand19hashmap_random_keys17h45c6c87c1f1ec840E+0x27): undefined reference to `getrandom'
collect2: error: ld returned 1 exit status
= help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
error: could not compile `polkadot` due to previous error
System info: Ubuntu 16.04.4 LTS
$ uname -a
Linux shield6 4.4.0-112-generic #135-Ubuntu SMP Fri Jan 19 11:48:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ rustc --version
rustc 1.62.1 (e092d0b6b 2022-07-16)
$ rustup --version
rustup 1.25.1 (bb60b1e89 2022-07-12)
It looks like some issues with the getrandom library but i am not very sure how to solve it. Appreciate any advice or suggestions.
I assume you tried deleting the target folder?