如何在 CentOS 7 上从源代码编译 Brotli
在此页
- 要求
- 初始步骤
- 构建 Brotli
- 链接
Brotli 是一种通用无损压缩算法,它结合使用 LZ77 算法的现代变体、霍夫曼编码和二阶上下文建模来压缩数据,其压缩率可与目前最好的通用压缩方法相媲美。它的速度与 deflate 相似,但提供更密集的压缩。它在 MIT 许可证下是开源的。你可以在 Github 上浏览它的源代码。 Brotli 压缩数据格式的规范在 RFC 7932 中定义。本教程介绍如何在 CentOS 7 系统上从源代码编译 Brotli 压缩库。
要求
- CentOS 7 系统。
- 具有 sudo 访问权限的非根用户。
初始步骤
检查 CentOS 版本:
cat /etc/centos-release
# CentOS Linux release 7.6.1810 (Core)
设置时区:
timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'
更新您的操作系统包:
sudo yum update -y
构建 Brotli
安装构建 Brotli 所需的构建工具和包:
sudo yum install -y wget gcc make bc sed autoconf automake libtool git tree
克隆 Brotli 存储库:
git clone https://github.com/google/brotli.git
导航到 Brotli 源代码树目录:
cd brotli
为 Brotli 命令创建手册页:
sudo cp ~/brotli/docs/brotli.1 /usr/share/man/man1 && sudo gzip /usr/share/man/man1/brotli.1
检查手册页:
man brotli
要生成 Autotools configure
文件,首先运行 ./bootstrap
命令:
./bootstrap
执行上述命令后,您应该可以访问通常的 C 程序构建步骤:configure
、make
和 make install
available。
如需帮助,您可以运行 ./configure --help
命令。现在我们准备好按照以下说明构建 Brotli。
构建和安装 brotli 的基本命令是:
./configure --prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib64/brotli \
--libdir=/usr/lib64/brotli \
--datarootdir=/usr/share \
--mandir=/usr/share/man/man1 \
--docdir=/usr/share/doc
make
sudo make install
成功构建过程后,您可以检查 Brotli 版本:
brotli --version
# brotli 1.0.7
要查看有关 brotli 命令的帮助,您可以运行:
brotli -h
链接
- https://brotli.org/
- https://github.com/google/brotli
- https://en.wikipedia.org/wiki/Brotli