故障排除 (Troubleshooting)

从源代码安装的故障排除 (Troubleshooting installation from source)

内存不足 (Not enough RAM)

在本地构建二进制文件是一项计算密集型任务,会对您的计算机进行测试。编译通常需要至少16 GB的RAM,根据您的机器的优化,可能需要稍微多一些(对于某些机器可能稍微少一些)。因此,编译有时可能会失败。

错误信息

src/apps/namada lib could not compile due to previous errors. Exited with exit code:

是一个常见的错误,有时可能意味着您的计算机在编译时内存不足。要解决此问题,我发现关闭所有其他应用程序并重新编译一两次就可以解决。否则,将需要更多的 RAM。

首次编译 (Compiling for the first time)

由于缺少库安装而导致的编译错误在首次构建二进制文件时可能是一个常见问题。

找不到链接器 "CC" (Linker "CC" not found)

如果遇到错误

Entering directory '/root/namada/wasm/wasm_source'
RUSTFLAGS='-C link-arg=-s'  cargo build --release --target wasm32-unknown-unknown --target-dir 'target' --features tx_bond && \
cp "./target/wasm32-unknown-unknown/release/namada_wasm.wasm" ../tx_bond.wasm
   Compiling proc-macro2 v1.0.46
   Compiling quote v1.0.21
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)
error: could not compile `quote` due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `proc-macro2` due to previous error

可以通过运行以下命令解决:

sudo apt install build-essential

另一个解决方案可能是安装 libcland-dev。可以通过以下命令实现:

sudo apt-get update -y
sudo apt-get install -y libclang-dev

WASM32-unknown-unknown

编译器可能会遇到的另一个问题是找不到 wasm32-unknown-unknown 目标。

error[E0463]: can't find crate for `core`
  |
  = note: the `wasm32-unknown-unknown` target may not be installed
  = help: consider downloading the target with `rustup target add wasm32-unknown-unknown`
error[E0463]: can't find crate for `compiler_builtins`
For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` due to 2 previous errors

此问题可以通过运行以下命令解决:

rustup target add wasm32-unknown-unknown

(是的,目标的名称就是 wasm32-unknown-unknown。这不是编译器无法告诉它是哪个版本/发布版)。

OpenSSL

如果遇到错误:

Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.
  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

那么解决方案已为您明确说明。您需要安装 OpenSSL 的开发包。对于 Ubuntu,这是 libssl-dev。对于 Fedora,这是 openssl-devel。对于其他发行版,请参考 OpenSSL 网站

对于 Ubuntu,可以通过以下命令实现:

sudo apt-get install libssl-dev

Last updated