Wednesday, June 1, 2016

build libzippp in visual studio 2013

Here are some c++ wrapper over libzip - https://github.com/ctabin/libzippp
But it has terrible building system
  • in it hardcoded version of visual studio (well, it's fixable)
  • in it hardcoded version of libzip (hardcoded version: 1.1.2, last version: 1.1.3 - well, and it's fixable)
  • it's difficult to change building script to adjust zlib & libzip - for example for static linking.
So, it's much easier to create empty project (god bless this project have one cpp & one h file (and one more cpp for tests - author has tests - that's really cool)). So, just create solution with 2 projects - libzippp & tests. Adjust headers, path to headers, lib files, path to lib files, change /MD to /MT & /MTd accordingly and build. Check if tests works fine. Done)

--------------------------------------------------------------------
and for using it as static library, go to libzippp.h, add #include <cstdint> and change:

#ifdef WIN32
        typedef long long libzippp_int64;
        typedef unsigned long long libzippp_uint64;
       
        //special declarations for windows to use libzippp from a DLL
        #define SHARED_LIBRARY_EXPORT __declspec(dllexport)
        #define SHARED_LIBRARY_IMPORT __declspec(dllimport)
#else
        //standard ISO c++ does not support long long
        typedef long int libzippp_int64;
        typedef unsigned long int libzippp_uint64;
       
        #define SHARED_LIBRARY_EXPORT
        #define SHARED_LIBRARY_IMPORT
#endif


to

typedef int64_t libzippp_int64;
typedef uint64_t libzippp_uint64;

#define SHARED_LIBRARY_EXPORT
#define SHARED_LIBRARY_IMPORT

--------------------------------------------------------------------


headers paths for libzippp:
D:\projects\libraries\libzip-1.1.3\lib
D:\projects\libraries\libzip-1.1.3\xcode


headers paths for tests:
D:\projects\libraries\libzippp\libzippp

lib paths for debug tests:
D:\projects\libraries\libzippp\x64\Debug
D:\projects\libraries\libzip-1.1.3\_build_x64_static_mt_mtd\lib\Debug
D:\projects\libraries\zlib-1.2.8\_libraries_debug


lib paths for release tests:
D:\projects\libraries\libzippp\x64\Release
D:\projects\libraries\libzip-1.1.3\_build_x64_static_mt_mtd\lib\Release
D:\projects\libraries\zlib-1.2.8\_libraries_release


lib files:
libzippp.lib
zipstatic.lib
zlibstat.lib


And respect for the author of libzippp - despite of bad building system, I hope project will be useful)
 

4 comments:

  1. Hello, thanks for your post.
    Maybe you can help to provide a better build system ?
    It's done like this in order to provide an easy way to build libzippp on Windows with VS2012 and CMake. Just by editing the compile.bat, it's easy to point to the correct library location, isn't it ?
    Best regards :)

    ReplyDelete
    Replies
    1. Just try to compile static x64 library with compile.bat and you will understand all my pain) I think it's impossible without complete rewriting compile.bat.

      > Maybe you can help to provide a better build system?
      No. sadly, but I don't have experience with creating building systems - just experience as user of such systems - build some project and include to my app. Make flexible building system from the scratch on bat scripts - it's not trivial and quick task) It's much easier for me to create new visual studio project and tune parameters for my case.

      Delete
  2. Hi, if possible, could you please provide a guide for how to make a precompiled static library of libzip that I can include in my CMake c++ project?

    ReplyDelete