1

I'm trying to compile libzip-1.3.0 on Windows 10 using cmake and MSVC2017.

I've successfully compiled that latest zlib (1.2.11), but when I try to compile libzip, I get told that: ZLIB version too old, please install at least v1.1.2

My zlib.h version definitions:

#define ZLIB_VERSION "1.2.11"
#define ZLIB_VERNUM 0x12b0
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
#define ZLIB_VER_REVISION 11
#define ZLIB_VER_SUBREVISION 0

The cmake command I'm running:

cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="C:\devel\lib\libzip" -DZLIB_LIBRARY:FILEPATH="C:\devel\lib\zlib\lib" -DZLIB_INCLUDE_DIR:PATH="C:\devel\lib\zlib"

I did find an old thread on the internet where someone else had a similar issue, but when I look at the relevant part of the CMakeLists.txt file, it looks like it is now correct:

FIND_PACKAGE(ZLIB REQUIRED)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR})
IF(ZLIB_VERSION_STRING VERSION_LESS "1.1.2")
  MESSAGE(FATAL_ERROR "-- ZLIB version too old, please install at least v1.1.2")
ENDIF(ZLIB_VERSION_STRING VERSION_LESS "1.1.2")

So - why is zlib 1.2.11 "older" than 1.1.2 and how do I get around this and compile libzip?

HorusKol
  • 8,375
  • 10
  • 51
  • 92

2 Answers2

1

Turns out, I was getting cmake to look in the wrong place - but instead of it reporting that zlib was not discovered, it made it seem like there was an old version of it instead.

The cmake command should use CMAKE_PREFIX_PATH and point to root of the zlib library (as below):

cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH="C:\devel\lib\zlib" -DCMAKE_INSTALL_PREFIX="C:\devel\lib\lipzip"
HorusKol
  • 8,375
  • 10
  • 51
  • 92
0

The cause of this problem may be that you provided the wrong ZLIB_INCLUDE_DIR, confirm zlib.h in this file directory and open zlib.h to see if the following line version number is greater than 1.1.2.

---zlib.h line number: 40---
#define ZLIB_VERSION "1.2.11"
#define ZLIB_VERNUM 0x12b0
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
#define ZLIB_VER_REVISION 11
#define ZLIB_VER_SUBREVISION 0