If you need libzip to compile and install software on CentOS, but the version installed by package manager Yum or DNF does not meet the requirement, you can follow this article to compile and install latest libzip in best practices.
We will use the currently latest version 1.8.0 of libzip as an example to show how to install libzip from source. The full process has been tested as working on CentOS 7, CentOS 8, and CentOS Stream 8. Problems that you may encounter during compilation are also specified in detail.
A root user role is required to follow the commands in this article. If you are not the root user, please make sure to add “sudo” before each command, or switch to the root user by command below:
We will use
yum command for any package related operation. Please note that on CenOS 8, CentOS Stream 8 and later versions of CentOS,
yum command is a symbolic link to
dnf binary and was replaced by
1 Prepare Environment
libzip is written mainly in C language. Before compiling libzip, we need to make sure C Compiler is installed on CentOS. We will use GCC (GNU Compiler Collection) as the C compiler. You can use any C compiler you like.
We also need to install two build automation tools of CMake and Make. CMake is used to generate project Buildsystem, including Makefiles consisting of a set of rules to tell Make tool how to compile programs from each other. With the configured Makefile, the second tool Make will build executable programs and libraries automatically from source code.
You may install GCC and Make on CentOS by following command:
yum install gcc make
The minimal CMake version for lipzip compliation is 3.0.2. For CentOS 8 and CentOS Stream 8, you may install CMake directly by command below:
yum install -y cmake
As for CentOS 7, the CMake version installed from package manager Yum is too low, thus we need to manually install the updated version. You may consult this article for detailed installation procedure:
No matter how you install CMake, please make sure you can get CMake version number from following command, and it is not lower than 3.0.2:
2 Download Source
We will get the download link of latest source package from:
- libzip Download Page: https://libzip.org/download/
There are two formats of package available: XZ (extension is .xz) and Gzip (extension is .gz). You may choose any of them as needed. Here we will use XZ format for the example.
First let us change the directory to system local source folder, then we will download the package using the link we got:
curl -LO https://libzip.org/download/libzip-1.8.0.tar.xz
We will unpack the libzip source package and switch to the directory of the source (note that we will stay in this directory for all operations unless otherwise specified):
tar -xvf libzip-1.8.0.tar.xz
3 Compile to Install
Since libzip compilation depends on many software libraries, we need to install these libraries before starting to compile. For specific dependencies, you can check INSTALL.md file in source folder for details. If a library is missing, the
cmake command we execute later will be interrupted to throw prompt.
To save time, you may run command below to install all dependencies for operation system directly:
yum install zlib-devel bzip2-devel xz-devel \
Please note that libzip supports 5 implementations of AES (Advanced Encryption Standard), which are Apple’s CommonCrypto, GnuTLS, mbed TLS, OpenSSL, and Microsoft Windows Cryptography Framework. We only need to choose one of them. The example in this article uses OpenSSL, so openssl-devel was installed.
Now we will generate the project Buildsystem with Makefile by following three commands:
cmake .. \
Please note that, there are four CMake options used here to configure libzip. Their meanings are specified as below:
|Specify the installation directory
|Specify to use OpenSSL as AES implementation
|Specify to disable other AES implementations that are automatically detected
After the execution of above commands, if progress reaches 100% and no error comes, you may run below command to start to compile:
After the compiling progress reaches 100% with no error, you may execute the command below to install libzip:
So far, we have finished the libzip compilation and installation.
4 Upgrade libzip
To upgrade libzip to a new version released in future, just follow all steps in this guide once more.
After all steps above, there are files and information that may be used by other softwares. We listed them as below for your reference.
Path of libzip configuration file for pkg-config:
Path of libzip header files:
Path of libzip library files:
If you have any problem to follow this guide, please leave a comment.