zstd/lib/README.md

86 lines
3.6 KiB
Markdown
Raw Normal View History

2016-08-29 11:04:26 +00:00
Zstandard library files
================================
2016-07-17 18:42:21 +00:00
The __lib__ directory contains several directories.
Depending on target use case, it's enough to include only files from relevant directories.
2016-07-17 18:42:21 +00:00
#### API
2016-04-25 09:31:28 +00:00
2016-07-17 18:42:21 +00:00
Zstandard's stable API is exposed within [zstd.h](zstd.h),
at the root of `lib` directory.
2016-03-10 00:09:41 +00:00
2016-07-17 18:42:21 +00:00
#### Advanced API
2016-04-25 09:36:44 +00:00
2016-07-17 18:42:21 +00:00
Some additional API may be useful if you're looking into advanced features :
2016-07-18 01:52:47 +00:00
- common/error_public.h : transforms `size_t` function results into an `enum`,
2016-07-17 18:42:21 +00:00
for precise error handling.
- ZSTD_STATIC_LINKING_ONLY : if you define this macro _before_ including `zstd.h`,
it will give access to advanced and experimental API.
These APIs shall ___never be used with dynamic library___ !
They are not "stable", their definition may change in the future.
Only static linking is allowed.
2016-04-25 09:31:28 +00:00
2017-04-19 00:03:37 +00:00
#### ZSTDMT API
To enable building the multithreaded compression API, use the `make lib-mt` target.
The header file zstdmt_compress.h (in compress/) provides the prototypes for the API.
If linking a program that uses the ZSTDMT API against libzstd.a on a POSIX system,
the -pthread flag must be provided to the compiler at link time.
Note that these prototypes may still be used in a version built without multithread support,
but they will be single threaded (i.e. no benefits will be given over the standard ZSTD API).
2016-04-25 09:31:28 +00:00
2016-07-17 18:42:21 +00:00
#### Modular build
2016-04-25 09:31:28 +00:00
2016-07-17 18:42:21 +00:00
Directory `common/` is required in all circumstances.
You can select to support compression only, by just adding files from the `compress/` directory,
In a similar way, you can build a decompressor-only library with the `decompress/` directory.
2016-03-10 00:09:41 +00:00
2016-07-17 18:42:21 +00:00
Other optional functionalities provided are :
2016-07-18 01:52:47 +00:00
- `dictBuilder/` : source files to create dictionaries.
2016-07-17 18:42:21 +00:00
The API can be consulted in `dictBuilder/zdict.h`.
2016-07-18 01:52:47 +00:00
This module also depends on `common/` and `compress/` .
2016-07-18 01:52:47 +00:00
- `legacy/` : source code to decompress previous versions of zstd, starting from `v0.1`.
This module also depends on `common/` and `decompress/` .
2016-08-13 22:16:20 +00:00
Library compilation must include directive `ZSTD_LEGACY_SUPPORT = 1` .
2016-07-18 01:52:47 +00:00
The main API can be consulted in `legacy/zstd_legacy.h`.
2016-08-13 22:16:20 +00:00
Advanced API from each version can be found in their relevant header file.
For example, advanced API for version `v0.4` is in `legacy/zstd_v04.h` .
2016-07-08 08:42:59 +00:00
#### Using MinGW+MSYS to create DLL
DLL can be created using MinGW+MSYS with the `make libzstd` command.
This command creates `dll\libzstd.dll` and the import library `dll\libzstd.lib`.
The import library is only required with Visual C++.
The header file `zstd.h` and the dynamic library `dll\libzstd.dll` are required to
compile a project using gcc/MinGW.
The dynamic library has to be added to linking options.
It means that if a project that uses ZSTD consists of a single `test-dll.c`
file it should be linked with `dll\libzstd.dll`. For example:
```
gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\libzstd.dll
```
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
2016-08-13 22:16:20 +00:00
#### Obsolete streaming API
2016-08-13 22:16:20 +00:00
Streaming is now provided within `zstd.h`.
Older streaming API is still available within `deprecated/zbuff.h`.
It will be removed in a future version.
Consider migrating code towards newer streaming API in `zstd.h`.
#### Miscellaneous
The other files are not source code. There are :
- LICENSE : contains the BSD license text
2016-07-17 18:42:21 +00:00
- Makefile : script to compile or install zstd library (static and dynamic)
- libzstd.pc.in : for pkg-config (`make install`)
2016-08-13 22:16:20 +00:00
- README.md : this file