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$