user1182183
user1182183

Reputation:

Standalone Cross Platform (Windows/Linux)) File Compression for C/C++?

I am looking for a (prefferably small) open source library in C or C++ which I can include in my MIT licensed projects (hosted on google code). I am a hobby C/C++ programmist so I am not that advanced, however I know just the things I need to develop plugins for a application named "SA-MP" (works on Windows and Linux). What I am willing to make is an auto installer which will need to be able to uncompress compressed files (prefferably .zip, but any other file compression method will do!).

I have looked for such a library but they always need to have some extra dll's on windows or some other files on linux - which is not the thing I am looking for as the end-users may not be able to know how to install the plugin with it's required components.

Looked also at Basic Compression Library and it seems it doesn't have file compression, but just algorithms. So with that one I'm out of luck.

To make the above text short:

Upvotes: 2

Views: 2058

Answers (2)

Cyan
Cyan

Reputation: 13948

Regarding compression libraries, there are several alternatives with low to very low dependancies. Zlib is really the first which comes to mind, but it's fair to say that its source tree alone is quite "crowded". That being said, i guess it does not depend on anything else special.

Much simpler, but also much lighter, you'll find alternatives such as LZ4, where the whole source code fills into a single file, and external dependancies are limited to stdlib and such.

You will probably have more difficulties in finding a portable library which scans directories, since such things tend to be OS dependant. I was thinking about Shelwien's Shar, but it may be tied to Windows.

Upvotes: 0

Jan Hudec
Jan Hudec

Reputation: 76246

What's wrong with zlib (that's the obvious first thing to look at; everybody uses that) or libzip (first hit on freshmeat)?

  • zlib: The library itself only provides the compression, but there is a sample implementation of zip format you can use. The "zlib license" is slightly modified MIT/X license, so should be compatible. Trivial to build as part of your application.
  • libzip: Supports zip format. BSD-revised license; you have to maintain it, but it's basically equivalent to MIT/X license. Can also be linked statically.

In general, there is no technical reason why you'd need to link anything dynamically. You don't. There is, however, a legal reason for LGPL-licensed libraries, because LGPL stops at dynamic object boundary, so static linking makes the other code LGPL as well.

Upvotes: 3

Related Questions