I recently compiled libzip (and zlib) statically on windows 10 and i'm playing with it on visual Studio 2017.I followed instructions on this thread,adapted it a bit to build with VS2017,and modified CMakelists.txt to build the library statically:
I added this to the end of the file :
ADD_LIBRARY(zipstatic STATIC ${LIBZIP_SOURCES} ${LIBZIP_EXTRA_FILES} ${LIBZIP_OPSYS_FILES})
SET_TARGET_PROPERTIES(zipstatic PROPERTIES VERSION 3.0 SOVERSION 3 )
TARGET_LINK_LIBRARIES(zipstatic ${ZLIB_LIBRARY} ${OPTIONAL_LIBRARY})
INSTALL(TARGETS zipstatic
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
I also used patch from here to get rid of STDIN_FILENO
error when compiling libzip.
Build processes went fine,i added zlibstatic.lib
and libzipstatic.lib
to my linker options,and set up Runtime Library to /MT
I wrote this tiny code to see if everything's working:
#include "stdafx.h"
#include <zip.h>
#include <zlib.h>
int main()
{
zip *archive = zip_open("C:\\test.zip", ZIP_CREATE, 0);
return 0;
}
This kind of error often appears when linking against static lib instead of DLL's,but i compiled libzip statically (and i need to use static linking),so what do I have to do ?
EDIT : zipstatic.lib summary:
C8 .data
60 .debug$F
45C4 .debug$S
21BD .drectve
2690 .rdata
113C1 .text$mn
and zlibstatic.lib's summary :
50 .debug$F
860 .debug$S
2C1 .drectve
4317 .rdata
ADB6 .text$mn