• Home
Name Date Size #Lines LOC

..--

dll/example/03-May-2024-342283

.gitignoreD03-May-202434 32

Android.bpD03-May-20241.1 KiB5349

LICENSED03-May-20241.3 KiB2520

MODULE_LICENSE_BSDD03-May-20240

MakefileD03-May-20248.2 KiB218147

README.mdD03-May-20245 KiB12188

liblz4-dll.rc.inD03-May-20241.1 KiB3634

liblz4.pc.inD03-May-2024385 1512

lz4.cD03-May-202498.9 KiB2,3991,669

lz4.hD03-May-202439 KiB765174

lz4frame.cD03-May-202476.3 KiB1,8611,309

lz4frame.hD03-May-202428 KiB616207

lz4frame_static.hD03-May-20242 KiB485

lz4hc.cD03-May-202464.8 KiB1,5391,200

lz4hc.hD03-May-202420.9 KiB439127

xxhash.cD03-May-202433.2 KiB1,031692

xxhash.hD03-May-202413.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 a worse compression ratio.
60  However, a smaller max distance can 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