下载
Zipper的地址为https://github.com/sebastiandev/zipper,以下载版本1.0.3为例,下载后文件为zipper-1.0.3.tar.gz。
编译
使用命令tar -zxvf zipper-1.0.3.tar.gz
进行解压,解压完成后文件夹zipper-1.0.3中目录结构如下:
[root@instance-1apocjsh zipper-1.0.3]# ls -al
total 232
drwxrwxr-x 6 root root 4096 Feb 16 2021 .
drwxr-xr-x 7 root root 4096 Jul 12 22:45 ..
-rw-rw-r-- 1 root root 1397 Feb 16 2021 appveyor.yml
-rw-rw-r-- 1 root root 17241 Feb 16 2021 CMakeLists.txt
-rw-rw-r-- 1 root root 111184 Feb 16 2021 Doxyfile
-rw-rw-r-- 1 root root 2308 Feb 16 2021 .gitignore
-rw-rw-r-- 1 root root 106 Feb 16 2021 .gitmodules
drwxrwxr-x 2 root root 4096 Feb 16 2021 .integration
-rw-rw-r-- 1 root root 1070 Feb 16 2021 LICENSE.md
-rw-rw-r-- 1 root root 22184 Feb 16 2021 logo.png
drwxrwxr-x 2 root root 4096 Feb 16 2021 minizip
-rw-rw-r-- 1 root root 8601 Feb 16 2021 README.md
drwxrwxr-x 2 root root 4096 Feb 16 2021 test
-rw-rw-r-- 1 root root 1151 Feb 16 2021 .travis.yml
-rw-rw-r-- 1 root root 6 Feb 16 2021 VERSION.txt
drwxrwxr-x 3 root root 4096 Feb 16 2021 zipper
-rw-rw-r-- 1 root root 829 Feb 16 2021 zipperConfig.cmake.in
-rw-rw-r-- 1 root root 322 Feb 16 2021 zipper.pc.cmakein
-rw-rw-r-- 1 root root 5558 Feb 16 2021 zipper.sln
注意此时minizip为空文件夹,需要自己手动进行下载。(在Zipper的主界面上,通过下图中标注minizip链接可直接跳转到minizip的Github页面)
下载minizip后,将其中的所有数据放入到Zipper目录下空的minizip中。
如果不进行这步操作,使用cmake ..
会报错:
CMake Error at CMakeLists.txt:273 (FILE):
FILE COPY cannot find "/root/test0712/zipper-1.0.3/minizip/zip.h": No such
file or directory.
注:编译Zipper需要使用zlib库,不过,当前使用的CentOS,已经预装了zlib,否则需要先行安装zlib。((通过上图中标注zlib链接可直接跳转到zlib的Github页面))
[root@instance-1apocjsh zipper-1.0.3]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@instance-1apocjsh zipper-1.0.3]# rpm -qa | grep zlib
zlib-1.2.7-18.el7.x86_64
使用命令mkdir build
创建构建目录,然后进入build中(cd build
),使用命令cmake ..
构建工程,
[root@instance-1apocjsh build]# cmake ..
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
--
----------------------------------------------------------------------
Zipper version 1.0.2
----------------------------------------------------------------------
Configured on host ''
host type = Linux
host operating system = Linux 3.10.0-1160.62.1.el7.x86_64
host CPU architecture = x86_64
General build flags:
CC = /usr/bin/cc
CXX = /usr/bin/c++
CPPFLAGS = -DLINUX
CFLAGS = -fno-strict-aliasing -fPIC
CXXFLAGS = -fno-strict-aliasing -fPIC
LDFLAGS =
Zlib library configuration:
Zlib library = /usr/local/lib/libz.so
Zlib include dir = /usr/local/include
Other configuration settings:
Installation $prefix = /usr/local
-- Configuring done
-- Generating done
-- Build files have been written to: /root/test0712/zipper-1.0.3/build
从上面的输出信息可知,Zlib library
、Zlib include dir
使用的是默认安装zlib的路径。如果是安装在其他路径,需要自己手动设置这两个变量。
再使用命令make -j16
进行编译,
[root@instance-1apocjsh build]# make -j16
...省略
最后使用命令make install DESTDIR=目标目录
进行安装。
[root@instance-1apocjsh build]# make install DESDIR=xxx
...省略
安装完成后,将目标目录中的include目录和lib目录放入到新建的Zipper目录,最终供外部使用的Zipper目录结构如下(去掉其中无用的文件、文件夹):
[root@instance-1apocjsh 3rd]# tree Zipper/
Zipper/
├── include
│ └── zipper
│ ├── CDirEntry.h
│ ├── crypt.h
│ ├── defs.h
│ ├── ioapi_buf.h
│ ├── ioapi.h
│ ├── ioapi_mem.h
│ ├── iowin32.h
│ ├── tools.h
│ ├── unzip.h
│ ├── unzipper.h
│ ├── zip.h
│ └── zipper.h
└── lib
├── libZipper.so -> libZipper.so.1
├── libZipper.so.1 -> libZipper.so.1.0.2
└── libZipper.so.1.0.2
3 directories, 15 files
使用
直接查看其Readme.md,非常详细。