Suppose I've defined

struct Data {
   std::string  fileName;
   char*        byteArray;
   size_t       size;

I want to be able to write something like the following:

std::vector<Data> vectorOfData; 
// ... filling vectorOfData here ...
ZIP zipArchive; // from some library?
for (int i = 0; i < vectorOfData.size(); i++
  const Data& d = vectorOfData[i];
  zipArchive.insert(d.filename, d.byteArray, d.size);

std::string outputDestination = "/home/output.zip"

Now, I know that's really, really simple. What I'm looking for is a library that has this functionality, and doesn't come with a massive amount of extra functionality that I'll get lost in, trying to figure out how it works.

My requirements are that the code has to be executed from within a C++ application (I can't write a script outside and call that, unfortunately!), and it needs to be cross-platform code, so I can compile on the 3 target platforms (Windows, OSX and Linux).

I have looked at zlib (which doesn't do zips), libzip (which doesn't have much in the way of examples, and has lots of extra functionality), and minizip (which has the same issue as libzip).

The reason I'm asking rather than trying to figure out the details of these large libraries is because I find it really surprising that a simple open-source solution doesn't exist. I'm more tempted to write one myself for my specific needs than rely on a large library that does too much, but I don't have time before the client needs the functionality :/

  • So, what's wrong with libzip and minizip other than the lack of examples?
    – einpoklum
    Commented Nov 26, 2017 at 21:58

1 Answer 1


You could try

Zipper - C++ wrappers around minizip

It's gratis and has an MIT license (plus the zlib license for the dependencies). It seems to be pretty straightforward to use, e.g.:

  • Creating a zip file with 2 files:

    using namespace zipper;
    std::ifstream input1("some file");
    std::ifstream input2("some file");
    Zipper zipper("ziptest.zip");
    zipper.add(input1, "Test1");
    zipper.add(input2, "Test1");
  • Adding a file by name and an entire folder to a zip:

    Zipper zipper("ziptest.zip");

You'll find more examples on the Zipper GitHub page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.