Linux之配置lzo压缩

前言

  • OS:CentOS 7
  • lzo:lzo-2.10
  • make:4.1
  • 本文主要演示如何编译lzo源码,生成lzo函数库,然后安装lzo工具lzop。
  • PS: 如果未安装make,则可以执行
sudo yum -y groupinstall "Development Tools"

sudo apt-get -y install build-essential

来安装Linux环境下基本开发编译工具包,其中就包含了gcc、g++、make等基本开发工具

  • 如果不想编译源码,也可以通过yumapt工具直接下载lzo依赖库,通过yum或apt工具的全文检索功能查找对应包包名,然后直接安装即可,如:
apt search lzo
yum search lzo

安装步骤

一、下载LZO源码

官网地址

lzo-2.10 下载地址

二、编译LZO源码

1)解压源码压缩包

tar -zxvf lzo-2.10.tar.gz -C /opt/module
mv /opt/module/lzo-2.10 /opt/module/lzo-2.10-src

2)创建文件夹用于保存编译后的输出文件

mkdir /opt/module/lzo-2.10-compiled

3)编译LZO源码

# 打开lzo源码所在路径
cd /opt/module/lzo-2.10-src
# 指定编译为64位应用程序
export CFLAGS=-m64
# 设置输出文件地址前缀
sudo ./configure -enable-shared -prefix=/opt/module/lzo-2.10-compiled
# 编译安装
sudo make && sudo make install

4)查看编译输出文件

ll -a /opt/module/lzo-2.10-compiled

若编译不报错,则在输出路径下会生成以下三个文件夹

tomandersen@localhost:/opt/module/lzo-2.10-compiled$ ll -a /opt/module/lzo-2.10-compiled
total 0
drwxr-xr-x 1 tomandersen cc   4096 Jun 10 20:15 ./
drwxr-xr-x 1 tomandersen cc   4096 Jun 10 17:22 ../
drwxr-xr-x 1 root        root 4096 Jun 10 20:15 include/
drwxr-xr-x 1 root        root 4096 Jun 10 20:15 lib/
drwxr-xr-x 1 root        root 4096 Jun 10 20:15 share/

5)将lzo-2.10-compiled/lib路径下的文件拷贝至指定文件夹内

若当前系统为64位,则将lib/liblzo*拷贝至/lib64/user/lib64,建议存放在/user/lib64

sudo cp /opt/module/lzo-2.10-compiled/lib/liblzo2* /usr/lib64/

若当前系统为32位,则拷贝至/lib/usr/local/,建议存放在后者路径下

sudo cp /opt/module/lzo-2.10-compiled/lib/liblzo2* /usr/lib/

三、安装lzop工具(可选)

lzop工具是基于lzo算法实现的压缩和解压工具,目前只支持压缩文件,不支持压缩文件夹。lzop只是一个工具,并未集成lzo算法函数库,因此使用此工具必须保证lzo算法函数库安装正确

sudo yum install lzop

sudo apt install lzop

使用方式:

tomandersen@localhost:/opt/module/lzo-2.10-compiled/lib$ lzop -h
                          Lempel-Ziv-Oberhumer Packer
                           Copyright (C) 1996 - 2010
lzop v1.03         Markus Franz Xaver Johannes Oberhumer          Nov 1st 2010

Usage: lzop [-dxlthIVL19] [-qvcfFnNPkUp] [-o file] [-S suffix] [file..]

Commands:
  -1     compress faster                   -9    compress better
  -d     decompress                        -x    extract (same as -dPp)
  -l     list compressed file              -I    display system information
  -t     test compressed file              -V    display version number
  -h     give this help                    -L    display software license
Options:
  -q     be quiet                          -v       be verbose
  -c     write on standard output          -oFILE   write output to 'FILE'
  -p     write output to current dir       -pDIR    write to path 'DIR'
  -f     force overwrite of output files
  -n     do not restore the original file name (default)
  -N     restore the original file name
  -P     restore or save the original path and file name
  -S.suf use suffix .suf on compressed files
  -U     delete input files after successful operation (like gzip and bzip2)
  file.. files to (de)compress. If none given, try standard input.

End~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章