centos7编译安装libzip-1.5.1
- 官网下载最新的libzip 地址
- centos上wget 下载
wget https://libzip.org/download/libzip-1.5.1.tar.gz
- 解压
tar -zxvf libzip-1.5.1.tar.gz
- 进入的libzip-1.5.1 目录
cd libzip-1.5.1
- 编译安装
mkdir build && cd build && cmake .. && make && make install
报错:
CMake Error at CMakeLists.txt:4 (CMAKE_MINIMUM_REQUIRED):
CMake 3.0.2 or higher is required. You are running version 2.8.12.2
解决办法:
- 卸载系统自带的cmake
yum remove cmake
- 官网下载最新的cmake 3.13.3 地址
- centos直接下载
wget https://github.com/Kitware/CMake/releases/download/v3.13.3/cmake-3.13.3.tar.gz
- 解压
tar -zxvf cmake-3.13.3.tar.gz
- 安装 gcc 等必备程序包(已经安装 gcc 则略过此步)
gcc 是 C 和 C++ 的编译工具,我的 CentOS 中有 gcc 所以就不用安装了,但是没有安装的话,执行以下命令:
yum install -y gcc gcc-c++ make automake
- 进入目录
cd cmake-3.13.3
- 执行编译
./bootstrap
- 安装
gmake && gmake install
- 测试看下安装成功没
cmake -version
/usr/bin/cmake: No such file or directory
因为直接使用cmake系统回到默认的/usr/bin中去寻找,但是src中安装的cmake是在/usr/local/bin中,所以当然不会找到。解决方法:
做一个链接即可:ln -s /usr/local/bin/cmake /usr/bin
然后使用/usr/local/bin/cmake进行编译。
继续安装 libzip
mkdir build && cd build && cmake .. && make && make install