cmake编译zipper错误提示: Please check that LIBZ_LIBRARY-NOTFOUND

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 99 12:33 CMakeCache.txt
drwxrwxr-x 36 tony tony 4.0K 99 12:33 CMakeFiles
-rw-rw-r--  1 tony tony 2.3K 99 12:33 cmake_install.cmake
-rw-r--r--  1 tony tony 3.6K 99 12:26 CPackConfig.cmake
-rw-r--r--  1 tony tony 4.0K 99 12:26 CPackSourceConfig.cmake
-rw-rw-r--  1 tony tony  428 99 12:33 CTestTestfile.cmake
-rw-r--r--  1 tony tony 2.6K 99 12:33 DartConfiguration.tcl
-rw-rw-r--  1 tony tony  40K 99 12:33 Makefile
drwxrwxr-x  3 tony tony 4.0K 99 12:33 Testing
drwxrwxr-x  2 tony tony 4.0K 99 12:33 zipper
tony@Fighting:~/linux/zipper/build$ ll /usr/lib/x86_64-linux-gnu/libz.so
lrwxrwxrwx 1 root root 35 34  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 99 12:34 libZipper-static.a
-rw-rw-r--  1 tony tony  40K 99 12:33 Makefile
-rwxrwxr-x  1 tony tony 749K 99 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$ 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fttony2020

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值