centos7 编译安装clang11.0
时间: 2023-07-17 10:05:31 浏览: 342
要在CentOS 7上编译安装Clang 11.0,您可以按照以下步骤进行操作:
1. 更新系统软件包:
```
sudo yum update
```
2. 安装依赖项:
```
sudo yum install epel-release
sudo yum install cmake gcc gcc-c++ wget python-devel zlib-devel
```
3. 下载Clang 11.0源代码:
```
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/llvm-11.0.0.src.tar.xz
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/clang-11.0.0.src.tar.xz
```
4. 解压源代码:
```
tar -xf llvm-11.0.0.src.tar.xz
tar -xf clang-11.0.0.src.tar.xz
```
5. 创建构建目录:
```
mkdir build && cd build
```
6. 运行CMake配置:
```
cmake -G "Unix Makefiles" ../llvm-11.0.0.src \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local/clang-11.0 \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_ENABLE_RTTI=ON
```
7. 编译并安装Clang:
```
make -j$(nproc)
sudo make install
```
8. 配置环境变量:
```
echo "export PATH=/usr/local/clang-11.0/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
```
现在,您应该已经成功编译安装了Clang 11.0。您可以通过运行以下命令来验证安装是否成功:
```
clang --version
```
希望对您有所帮助!如有任何问题,请随时提问。
阅读全文