版权声明:版权归版主所有,转载需要声明出处 https://blog.csdn.net/fightingTony/article/details/82557593
cmake编译zipper错误提示: Please check that LIBZ_LIBRARY-NOTFOUND
解决问题
操作系统:
ubuntu 16.04 14.04
编译方式:
cmake gcc g++
移植zipper 支持zip库压缩
zipper c++下载地址
https://github.com/sebastiandev/zipper
编译方法
安装好cmake,编译zipper错误,没有能生成我们想要的Makefile编译脚本
$ cd zipper
$ mkdir build
$ cmake ../
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning at CMakeLists.txt:158 (message):
The chosen zlib library does not appear to be valid because it is
missing certain required symbols. Please check that LIBZ_LIBRARY-NOTFOUND
is
the correct zlib library. For details about the error, please see
/home/tony/linux/zipper/build/CMakeFiles/CMakeError.log
CMake Error at CMakeLists.txt:167 (message):
The include directory specified for zlib does not appear to be
valid. It should contain the file zlib.h, but it does not. Please
verify the LIBZ_INCLUDE_DIR variable.
-- Configuring incomplete, errors occurred!
这时安装提示的zlib工具即可
解决方法
tony@Fighting:~/linux/zipper/build$ sudo apt install -y libz-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
注意,选中 'zlib1g-dev' 而非 'libz-dev'
下列软件包是自动安装的并且现在不需要了:
linux-headers-4.4.0-127 linux-headers-4.4.0-127-generic linux-headers-4.4.0-130 linux-headers-4.4.0-130-generic linux-image-4.4.0-127-generic linux-image-4.4.0-130-generic
linux-image-extra-4.4.0-127-generic linux-image-extra-4.4.0-130-generic linux-signed-image-4.4.0-127-generic linux-signed-image-4.4.0-130-generic
使用'sudo apt autoremove'来卸载它(它们)。
下列【新】软件包将被安装:
zlib1g-dev
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 136 个软件包未被升级。
需要下载 168 kB 的归档。
解压缩后会消耗 425 kB 的额外空间。
获取:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4.1 [168 kB]
已下载 168 kB,耗时 2秒 (81.6 kB/s)
正在选中未选择的软件包 zlib1g-dev:amd64。
(正在读取数据库 ... 系统当前共安装有 298247 个文件和目录。)
正准备解包 .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4.1_amd64.deb ...
正在解包 zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
正在处理用于 man-db (2.7.5-1) 的触发器 ...
正在设置 zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
tony@Fighting:~/linux/zipper/build$ cmake ../
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning at CMakeLists.txt:158 (message):
The chosen zlib library does not appear to be valid because it is
missing certain required symbols. Please check that
/usr/lib/x86_64-linux-gnu/libz.so is
the correct zlib library. For details about the error, please see
/home/tony/linux/zipper/build/CMakeFiles/CMakeError.log
--
----------------------------------------------------------------------
Zipper version 0.9.1
----------------------------------------------------------------------
Configured on host ''
host type = Linux
host operating system = Linux 4.4.0-134-generic
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/lib/x86_64-linux-gnu/libz.so
Zlib include dir = /usr/include
Other configuration settings:
Installation $prefix = /usr/local
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tony/linux/zipper/build
tony@Fighting:~/linux/zipper/build$ ll
总用量 92K
-rw-rw-r-- 1 tony tony 18K 9月 9 12:33 CMakeCache.txt
drwxrwxr-x 36 tony tony 4.0K 9月 9 12:33 CMakeFiles
-rw-rw-r-- 1 tony tony 2.3K 9月 9 12:33 cmake_install.cmake
-rw-r--r-- 1 tony tony 3.6K 9月 9 12:26 CPackConfig.cmake
-rw-r--r-- 1 tony tony 4.0K 9月 9 12:26 CPackSourceConfig.cmake
-rw-rw-r-- 1 tony tony 428 9月 9 12:33 CTestTestfile.cmake
-rw-r--r-- 1 tony tony 2.6K 9月 9 12:33 DartConfiguration.tcl
-rw-rw-r-- 1 tony tony 40K 9月 9 12:33 Makefile
drwxrwxr-x 3 tony tony 4.0K 9月 9 12:33 Testing
drwxrwxr-x 2 tony tony 4.0K 9月 9 12:33 zipper
tony@Fighting:~/linux/zipper/build$ ll /usr/lib/x86_64-linux-gnu/libz.so
lrwxrwxrwx 1 root root 35 3月 4 2017 /usr/lib/x86_64-linux-gnu/libz.so -> /lib/x86_64-linux-gnu/libz.so.1.2.8
到这里就可以看到编译通过的帮助打印已经show出来的,而且Makefile也已经生成,libz.so也已经安装好。
编译zipper 库
tony@Fighting:~/linux/zipper/build$ make -j12
Scanning dependencies of target Zipper-static
[ 4%] Building C object CMakeFiles/Zipper-static.dir/minizip/aes/prng.c.o
[ 13%] Building C object CMakeFiles/Zipper-static.dir/minizip/ioapi_buf.c.o
[ 82%] Linking CXX static library libZipper-static.a
[ 82%] Built target Zipper-static
Scanning dependencies of target Zipper-test
[ 95%] Building CXX object CMakeFiles/Zipper-test.dir/test/memory_zip_test.cpp.o
[100%] Linking CXX executable Zipper-test
[100%] Built target Zipper-test
生成libZipper-static.a静态库和测试程序Zipper-test
tony@Fighting:~/linux/zipper/build$ ll
总用量 1.2M
-rw-rw-r-- 1 tony tony 314K 9月 9 12:34 libZipper-static.a
-rw-rw-r-- 1 tony tony 40K 9月 9 12:33 Makefile
-rwxrwxr-x 1 tony tony 749K 9月 9 12:34 Zipper-test
tony@Fighting:~/linux/zipper/build$ ./Zipper-test
===============================================================================
All tests passed (42 assertions in 2 test cases)
tony@Fighting:~/linux/zipper/build$