views:

212

answers:

6

Hello,

I was reading about compression in programs and I started to create a new simple project, a zipper (just a zipper, not an unzipper), but I only found zLib, and it's for C. I know that C libraries can be used in C++, but I like to use C++ libraries. Does anyone know a good one to suggest?

Best Regards.

+1  A: 

I would suggest using zlib. It is designed for C, but it works fine in C++.

Using native C++ libraries really only helps when the library is sufficiently big and complex that it can benefit from object oriented design. zlib is relatively simple, and doesn't need object oriented features.

Zifre
+4  A: 

Most compression libraries that I know of are written in C for two reasons: one, the general age of good compression algorithms; and two, the high portability (and stability) of C across platforms.

I suggest any of the following. If you want good licenses select one of the top two, otherwise if you're open to using GPL code pick one of the last two.

The Wicked Flea
+5  A: 

You could do this easily using Boost iostream zlib filter

Locksfree
+1  A: 

Use libzip: http://www.nih.at/libzip/ The license is pretty permissive and it does all you need, from C or C++ code.

Joe
A: 

zlib is strongly recommended. It is well written and the interface is fairly clean. I do not see how much a C++ wrapper can simplify APIs. Furthermore, in my view, zlib achieves a good balance between (de)compression speed and file size. Bzip2 is too slow while the compression ratio of LZO and UCL is too bad. Use zlib, please.

Zlib interface looks a bit weird to me. I prefer the boost::iostreams wrap, much saner.
piotr
+1  A: 

Zlib is good, but you might want to check the LZMA SDK as well (you could compress to .7z format, in addition to zip)

Rajesh R Subramanian