• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..16-Nov-2021-

dll/example/H25-Jun-2019-342283

.gitignoreH A D25-Jun-201934 32

LICENSEH A D25-Jun-20191.3 KiB2520

MakefileH A D25-Jun-20198.2 KiB218147

README.mdH A D25-Jun-20195 KiB12188

liblz4-dll.rc.inH A D25-Jun-20191.1 KiB3634

liblz4.pc.inH A D25-Jun-2019385 1512

lz4.cH A D25-Jun-201994.9 KiB2,3131,623

lz4.hH A D25-Jun-201939 KiB765174

lz4frame.cH A D25-Jun-201975.8 KiB1,8401,288

lz4frame.hH A D25-Jun-201928 KiB616207

lz4frame_static.hH A D25-Jun-20192 KiB485

lz4hc.cH A D25-Jun-201961.4 KiB1,4771,151

lz4hc.hH A D25-Jun-201920.9 KiB439127

xxhash.cH A D25-Jun-201933.2 KiB1,031692

xxhash.hH A D25-Jun-201913.2 KiB329136

README.md

1LZ4 - Library Files
2================================
3
4The `/lib` directory contains many files, but depending on project's objectives,
5not all of them are necessary.
6
7#### Minimal LZ4 build
8
9The minimum required is **`lz4.c`** and **`lz4.h`**,
10which provides the fast compression and decompression algorithms.
11They generate and decode data using the [LZ4 block format].
12
13
14#### High Compression variant
15
16For more compression ratio at the cost of compression speed,
17the High Compression variant called **lz4hc** is available.
18Add files **`lz4hc.c`** and **`lz4hc.h`**.
19This variant also compresses data using the [LZ4 block format],
20and depends on regular `lib/lz4.*` source files.
21
22
23#### Frame support, for interoperability
24
25In order to produce compressed data compatible with `lz4` command line utility,
26it's necessary to use the [official interoperable frame format].
27This format is generated and decoded automatically by the **lz4frame** library.
28Its public API is described in `lib/lz4frame.h`.
29In order to work properly, lz4frame needs all other modules present in `/lib`,
30including, lz4 and lz4hc, and also **xxhash**.
31So it's necessary to include all `*.c` and `*.h` files present in `/lib`.
32
33
34#### Advanced / Experimental API
35
36Definitions which are not guaranteed to remain stable in future versions,
37are protected behind macros, such as `LZ4_STATIC_LINKING_ONLY`.
38As the name implies, these definitions can only be invoked
39in the context of static linking ***only***.
40Otherwise, dependent application may fail on API or ABI break in the future.
41The associated symbols are also not present in dynamic library by default.
42Should they be nonetheless needed, it's possible to force their publication
43by using build macro `LZ4_PUBLISH_STATIC_FUNCTIONS`.
44
45
46#### Build macros
47
48The following build macro can be selected at compilation time :
49
50- `LZ4_FAST_DEC_LOOP` : this triggers the optimized decompression loop.
51  This loops works great on x86/x64 cpus, and is automatically enabled on this platform.
52  It's possible to enable or disable it manually, by passing `LZ4_FAST_DEC_LOOP=1` or `0` to the preprocessor.
53  For example, with `gcc` : `-DLZ4_FAST_DEC_LOOP=1`,
54  and with `make` : `CPPFLAGS+=-DLZ4_FAST_DEC_LOOP=1 make lz4`.
55
56- `LZ4_DISTANCE_MAX` : control the maximum offset that the compressor will allow.
57  Set to 65535 by default, which is the maximum value supported by lz4 format.
58  Reducing maximum distance will reduce opportunities for LZ4 to find matches,
59  hence will produce worse the compression ratio.
60  However, a smaller max distance may allow compatibility with specific decoders using limited memory budget.
61  This build macro only influences the compressed output of the compressor.
62
63- `LZ4_DISABLE_DEPRECATE_WARNINGS` : invoking a deprecated function will make the compiler generate a warning.
64  This is meant to invite users to update their source code.
65  Should this be a problem, it's generally possible to make the compiler ignore these warnings,
66  for example with `-Wno-deprecated-declarations` on `gcc`,
67  or `_CRT_SECURE_NO_WARNINGS` for Visual Studio.
68  Another method is to define `LZ4_DISABLE_DEPRECATE_WARNINGS`
69  before including the LZ4 header files.
70
71
72#### Amalgamation
73
74lz4 source code can be amalgamated into a single file.
75One can combine all source code into `lz4_all.c` by using following command:
76```
77cat lz4.c lz4hc.c lz4frame.c > lz4_all.c
78```
79(`cat` file order is important) then compile `lz4_all.c`.
80All `*.h` files present in `/lib` remain necessary to compile `lz4_all.c`.
81
82
83#### Windows : using MinGW+MSYS to create DLL
84
85DLL can be created using MinGW+MSYS with the `make liblz4` command.
86This command creates `dll\liblz4.dll` and the import library `dll\liblz4.lib`.
87To override the `dlltool` command  when cross-compiling on Linux, just set the `DLLTOOL` variable. Example of cross compilation on Linux with mingw-w64 64 bits:
88```
89make BUILD_STATIC=no CC=x86_64-w64-mingw32-gcc DLLTOOL=x86_64-w64-mingw32-dlltool OS=Windows_NT
90```
91The import library is only required with Visual C++.
92The header files `lz4.h`, `lz4hc.h`, `lz4frame.h` and the dynamic library
93`dll\liblz4.dll` are required to compile a project using gcc/MinGW.
94The dynamic library has to be added to linking options.
95It means that if a project that uses LZ4 consists of a single `test-dll.c`
96file it should be linked with `dll\liblz4.dll`. For example:
97```
98    $(CC) $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\liblz4.dll
99```
100The compiled executable will require LZ4 DLL which is available at `dll\liblz4.dll`.
101
102
103#### Miscellaneous
104
105Other files present in the directory are not source code. There are :
106
107 - `LICENSE` : contains the BSD license text
108 - `Makefile` : `make` script to compile and install lz4 library (static and dynamic)
109 - `liblz4.pc.in` : for `pkg-config` (used in `make install`)
110 - `README.md` : this file
111
112[official interoperable frame format]: ../doc/lz4_Frame_format.md
113[LZ4 block format]: ../doc/lz4_Block_format.md
114
115
116#### License
117
118All source material within __lib__ directory are BSD 2-Clause licensed.
119See [LICENSE](LICENSE) for details.
120The license is also reminded at the top of each source file.
121