前言
安装编译polkadot源码时候报错,看了下Clang版本低了,刚开始使用的是yum安装的。
[centos@kaiyuan-test polkadot]$ cargo build --release
Compiling secp256k1 v0.24.2
Compiling librocksdb-sys v0.8.0+7.4.4
error: failed to run custom build command for `librocksdb-sys v0.8.0+7.4.4`
Caused by:
process didn't exit successfully: `/data/polkadot/target/release/build/librocksdb-sys-3093ccca9a1b6120/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at '`libclang` function not loaded: `clang_getTranslationUnitTargetInfo`. This crate requires that `libclang` 3.9 or later be installed on your system. For more information on how to accomplish this, see here: https://rust-lang.github.io/rust-bindgen/requirements.html#installing-clang-39', /home/centos/.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-1.3.0/src/lib.rs:1704:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
clang --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
安装环境包
编译LLVM需要事先在系统中安装符合以下条件的软件
CMake >= 3.4.3cmake --version
GCC >= 5.1.0gcc -v
Python >= 2.7
zlib >= 1.2.3.4
GNU Make >= 3.79
安装gcc、g++、perl
sudo yum install gcc gcc-c++ perl
安装cmake
下载地址:https://cmake.org/download/
sudo wget https://github.com/Kitware/CMake/releases/download/v3.26.0-rc5/cmake-3.26.0-rc5.tar.gz
tar zxvf cmake-3.26.0-rc5.tar.gz
cd cmake-3.26.0-rc5/
sudo ./bootstrap
sudo gmake
sudo make install
# 查看版本
cmake --version
Clang安装
下载地址(15.0.0版本):
http://llvm.org/releases/download.html
https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.0
下载源码:
sudo wget https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/llvm-15.0.0.src.tar.xz
sudo wget https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/clang-15.0.0.src.tar.xz
sudo wget https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/clang-tools-extra-15.0.0.src.tar.xz
sudo tar -xvf llvm-15.0.0.src.tar.xz #重命名为 llvm
sudo tar -xvf clang-15.0.0.src.tar.xz #重命名为 clang
sudo tar -xf clang-tools-extra-15.0.0.src.tar.xz #重命名为 clang-tools-extra
# 移动clang到llvm/tools/目录下
sudo mv clang llvm/tools/
# 移动clang-tools-extra到llvm/tools/clang/tools/目录下
sudo mv clang-tools-extra llvm/tools/clang/tools/
cd llvm
./configure
# 报错,新版本不支持configure安装了
# The LLVM project no longer supports building with configure & make.
安装命令
# llvm 同级目录下创建 build
sudo mkdir build
/usr/local/bin/cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="/usr/local/llvm" ../llvm/
# cmake -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE="Release" -DLLVM_INCLUDE_TESTS=OFF -DCMAKE_INSTALL_PREFIX="/usr/local/llvm" ../llvm
make
make instal
参考文档
https://llvm.org/docs/CMake.html
本文介绍了如何在Linux CentOS系统中安装Clang,特别是为了解决编译Polkadot源码时遇到的版本过低问题。首先需要安装必要的环境包,包括gcc、g++、perl和cmake。接着,提供了Clang 15.0.0版本的下载链接,并详细说明了下载源码和安装的步骤,参考了官方CMake文档。
4519

被折叠的 条评论
为什么被折叠?



