1e41f4b71Sopenharmony_ci# zlib
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## Introduction
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci[zlib](https://zlib.net/) is a general data compression library implemented in C/C++.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci## Supported Capabilities
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciThe zlib library provides in-momery data compression and decompression. By employing the deflate algorithm, it is possible to select from various compression levels to optimize the compression performance for a range of data types. It also provides control over processor and memory usage. If the buffer is large enough, the compression process can be completed in a single step. In cases where the buffer is not large enough, the compression can be completed through multiple iterations of calling the compression interfaces.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciBy default, the zlib interfaces use the zlib format ([RFC1950](https://www.rfc-editor.org/rfc/rfc1950)). In addition, the zlib library provides interfaces that start with gz to read and write gzip files ([RFC1952](https://www.rfc-editor.org/rfc/rfc1952)). The zlib format is designed for efficient use in memory and communication channels, ensuring both compactness and swift performance. The gzip format is designed for the compression of individual files. Its header is larger than that of zlib in order to maintain directory information. gzip uses a check method that, while different, is comparatively slower than the one used by zlib.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ciThe decoder within the zlib library checks the integrity of compressed data. Therefore, the library will not crash even in the case of corrupted input.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Introducing zlib
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciTo use zlib capabilities, include the following header file:
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci```c
20e41f4b71Sopenharmony_ci#include <zlib.h>
21e41f4b71Sopenharmony_ci```
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ciAdd the following dynamic link library to **CMakeLists.txt**:
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci```
26e41f4b71Sopenharmony_cilibz.so
27e41f4b71Sopenharmony_ci```
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## Supported APIs
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ciFor details, see [zlib](https://www.zlib.net/manual.html).
32