How to build libzip library?

5.9k Views Asked by At

I'm having problems when trying to build it on Windows 10 x64.

My environ is

MingGW 3.20
CMake 3.3.0

libzip-1.0.1

What I did was download the project in libzip site, open to CLion IDE (last version) and try to compile.

The entire build process with errors, can be found in the link. http://pastebin.com/KTPtm5z3

A number of undeclared variables appears as error:

error: 'EOPNOTSUPP' undeclared (first use in this function)

What is causing this problem and why ?

I can compile the library version libzip without any problem in this repository mirror repo libzip v0.9, but I want to the latest version of libzip.

2

There are 2 best solutions below

0
On

Using the mailing list: http://www.nih.at/listarchive/libzip-discuss/

Several changes have been incorporated into the build process on Windows.

The ending here http://nih.at/listarchive/libzip-discuss/msg00574.html

The end result could not be better! They solved all the problems and I could build libzip in Windows.

Thank you all.

2
On

The libzip developers have been made aware of this question but seem to be troubled with finding the right fix as neither of them is very familiar with Windows or MinGW: http://nih.at/listarchive/libzip-discuss/msg00559.html

I'm not familiar with either myself but was recently able to successfully compile libzip on Windows 7 (without MinGW) using this answer (also see my comment to that answer): https://stackoverflow.com/a/30245321/784669

Finally, since you might want to get things running right now, try to do the following:

  • your call to swprintf in lib/zip_source_win32w.c, line 36, try to just delete the second argument to the function len as your compiler seems to assume an older version of swprintf
  • put the following code as a temporary implementation for GetFileSizeEx (credit: https://sourceforge.net/p/tdm-gcc/bugs/250/):

_

bool GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER fsize){
    LPDWORD tSize;
    DWORD t = fsize->HighPart;
    *tSize = t;
    int ret = GetFileSize(hFile, tSize);
    fsize->HighPart = *tSize;
    delete tSize;
    return ret;
}
  • and here is another suggestion for GetFileSizeEx from stackoverflow: https://stackoverflow.com/a/28028376/784669 So the problem might be your Windows version. Indeed in winbase.h it says to only define GetFileSizeEx if _WIN32_WINNT >= 0x0500. Maybe your Windows version is too old or you need to:

_

#define _WIN32_WINNT 0x0500

Good luck!