Substrate: cargo build -> librocksdb-sys v5.14.2 -> unable to find libclang ... libclang.so

Created on 8 Jul 2019  路  6Comments  路  Source: paritytech/substrate

summary of the problem:

cargo build -> librocksdb-sys v5.14.2 -> Unable to find libclang ... libclang.so

what I did:

git clone https://github.com/paritytech/substrate.git paritytech_substrate
cd paritytech_substrate/
git checkout v0.9.2

./scripts/init.sh
./scripts/build.sh
cargo build

about git checkout v0.9.2 see https://github.com/paritytech/substrate/issues/3066

system is Debian 9

uname -a; rustc --version
Linux ... 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u3 (2019-06-16) x86_64 GNU/Linux
rustc 1.36.0 (a53f9df32 2019-07-03)

details:

cargo build
[...]

Compiling librocksdb-sys v5.14.2
error: failed to run custom build command for `librocksdb-sys v5.14.2`

Caused by:
  process didn't exit successfully: `~/paritytech_substrate/target/debug/build/librocksdb-sys-a0f791c907b0f400/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=rocksdb/
cargo:rerun-if-changed=snappy/

--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any of [\'libclang.so\', \'libclang.so.*\', \'libclang-*.so\'], set the LIBCLANG_PATH environment variable to a path where one of these files can be found (skipped: [])"', src/libcore/result.rs:999:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
warning: unused import: `ConstructRuntimeApi`
  --> core/client/src/client.rs:33:51
   |
33 | use runtime_api::{Core as CoreAPI, CallRuntimeAt, ConstructRuntimeApi};
   |                                                   ^^^^^^^^^^^^^^^^^^^

warning: variable does not need to be mutable
   --> core/client/src/client.rs:578:9
    |
578 |                 let mut r = self.executor.call_at_state(
    |                     ----^
    |                     |
    |                     help: remove this `mut`
    |
    = note: #[warn(unused_mut)] on by default

warning: static variable `__CacheGetByteStructAccountNonce` should have an upper case name
   --> srml/system/src/lib.rs:187:7
    |
187 |         pub AccountNonce get(account_nonce): map T::AccountId => T::Index;
    |             ^^^^^^^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_ACCOUNT_NONCE`
    |
    = note: #[warn(non_upper_case_globals)] on by default

warning: static variable `__CacheGetByteStructExtrinsicCount` should have an upper case name
   --> srml/system/src/lib.rs:189:3
    |
189 |         ExtrinsicCount: Option<u32>;
    |         ^^^^^^^^^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_EXTRINSIC_COUNT`

warning: static variable `__CacheGetByteStructBlockHash` should have an upper case name
   --> srml/system/src/lib.rs:190:7
    |
190 |         pub BlockHash get(block_hash) build(|_| vec![(T::BlockNumber::zero(), [69u8; 32])]): map T::BlockNumber => T::Hash;
    |             ^^^^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_BLOCK_HASH`

warning: static variable `__CacheGetByteStructExtrinsicData` should have an upper case name
   --> srml/system/src/lib.rs:191:3
    |
191 |         ExtrinsicData get(extrinsic_data): map u32 => Vec<u8>;
    |         ^^^^^^^^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_EXTRINSIC_DATA`

warning: static variable `__CacheGetByteStructRandomSeed` should have an upper case name
   --> srml/system/src/lib.rs:192:3
    |
192 |         RandomSeed get(random_seed) build(|_| [0u8; 32]): T::Hash;
    |         ^^^^^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_RANDOM_SEED`

warning: static variable `__CacheGetByteStructNumber` should have an upper case name
   --> srml/system/src/lib.rs:194:3
    |
194 |         Number get(block_number) build(|_| 1u64): T::BlockNumber;
    |         ^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_NUMBER`

warning: static variable `__CacheGetByteStructParentHash` should have an upper case name
   --> srml/system/src/lib.rs:195:3
    |
195 |         ParentHash get(parent_hash) build(|_| [69u8; 32]): T::Hash;
    |         ^^^^^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_PARENT_HASH`

warning: static variable `__CacheGetByteStructExtrinsicsRoot` should have an upper case name
   --> srml/system/src/lib.rs:196:3
    |
196 |         ExtrinsicsRoot get(extrinsics_root): T::Hash;
    |         ^^^^^^^^^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_EXTRINSICS_ROOT`

warning: static variable `__CacheGetByteStructDigest` should have an upper case name
   --> srml/system/src/lib.rs:197:3
    |
197 |         Digest get(digest): T::Digest;
    |         ^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_DIGEST`

warning: static variable `__CacheGetByteStructEvents` should have an upper case name
   --> srml/system/src/lib.rs:199:3
    |
199 |         Events get(events): Vec<EventRecord<T::Event>>;
    |         ^^^^^^ help: convert the identifier to upper case: `__CACHE_GET_BYTE_STRUCT_EVENTS`

error: build failed

what is libclang, and why don't I have that?

locate libclang.so
/var/lib/flatpak/runtime/org.gnome.Sdk/x86_64/3.26/980d2621abd9214c354c9f1a40286d366d8687cfa4066eb21ccb5e7083df80fd/files/lib/libclang.so
/var/lib/flatpak/runtime/org.gnome.Sdk/x86_64/3.26/980d2621abd9214c354c9f1a40286d366d8687cfa4066eb21ccb5e7083df80fd/files/lib/libclang.so.4
/var/lib/flatpak/runtime/org.gnome.Sdk/x86_64/3.26/980d2621abd9214c354c9f1a40286d366d8687cfa4066eb21ccb5e7083df80fd/files/lib/libclang.so.4.0

so it's there, but deep inside flatpak.

What to do?

All 6 comments

was easy to fix:

 sudo apt-get install -y clang

I guess, that dependency was missing from some initialization file, perhaps your

./scripts/init.sh

?

It's specified in the README (https://github.com/paritytech/substrate#6-building). Our scripts don't manage system dependencies.

Thanks. Eventually I found it out myself anyways.

I suggest you add that info to this page then: https://substrate.dev/docs/en/getting-started/installing-substrate#manual-build ... that is what I was following, as part of the official instructions.

Oh, and yey, what a relief: I found a way to get rid of all those -for me- useless warnings:

RUSTFLAGS=-Awarnings cargo build

Anyways, thanks.

Agreed it probably makes sense to be there. cc @shawntabrizi

Ack. In general, you should make sure all dependencies needed for your computer are installed using:

curl https://getsubstrate.io -sSf | bash -s -- --fast

If you want to see what it does, you can simply go to https://getsubstrate.io

Yes, now I got it: cmake pkg-config libssl-dev git gcc build-essential clang libclang-dev

If you want to avoid redundancy, why not just put the same sentence "... want to see what it does ..." into the "Manual Build" chapter.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomaka picture tomaka  路  5Comments

JoshOrndorff picture JoshOrndorff  路  4Comments

tomaka picture tomaka  路  4Comments

jiangfuyao picture jiangfuyao  路  3Comments

pepyakin picture pepyakin  路  5Comments