xref: /aosp_15_r20/external/lz4/lib/dll/example/README.md (revision 27162e4e17433d5aa7cb38e7b6a433a09405fc7f)
1*27162e4eSAndroid Build Coastguard WorkerLZ4 Windows binary package
2*27162e4eSAndroid Build Coastguard Worker====================================
3*27162e4eSAndroid Build Coastguard Worker
4*27162e4eSAndroid Build Coastguard Worker#### The package contents
5*27162e4eSAndroid Build Coastguard Worker
6*27162e4eSAndroid Build Coastguard Worker- `lz4.exe`                  : Command Line Utility, supporting gzip-like arguments
7*27162e4eSAndroid Build Coastguard Worker- `dll\msys-lz4-1.dll`       : The DLL of LZ4 library, compiled by msys
8*27162e4eSAndroid Build Coastguard Worker- `dll\liblz4.dll.a`         : The import library of LZ4 library for Visual C++
9*27162e4eSAndroid Build Coastguard Worker- `example\`                 : The example of usage of LZ4 library
10*27162e4eSAndroid Build Coastguard Worker- `include\`                 : Header files required with LZ4 library
11*27162e4eSAndroid Build Coastguard Worker- `static\liblz4_static.lib` : The static LZ4 library
12*27162e4eSAndroid Build Coastguard Worker
13*27162e4eSAndroid Build Coastguard Worker
14*27162e4eSAndroid Build Coastguard Worker#### Usage of Command Line Interface
15*27162e4eSAndroid Build Coastguard Worker
16*27162e4eSAndroid Build Coastguard WorkerCommand Line Interface (CLI) supports gzip-like arguments.
17*27162e4eSAndroid Build Coastguard WorkerBy default CLI takes an input file and compresses it to an output file:
18*27162e4eSAndroid Build Coastguard Worker```
19*27162e4eSAndroid Build Coastguard Worker    Usage: lz4 [arg] [input] [output]
20*27162e4eSAndroid Build Coastguard Worker```
21*27162e4eSAndroid Build Coastguard WorkerThe full list of commands for CLI can be obtained with `-h` or `-H`. The ratio can
22*27162e4eSAndroid Build Coastguard Workerbe improved with commands from `-3` to `-16` but higher levels also have slower
23*27162e4eSAndroid Build Coastguard Workercompression. CLI includes in-memory compression benchmark module with compression
24*27162e4eSAndroid Build Coastguard Workerlevels starting from `-b` and ending with `-e` with iteration time of `-i` seconds.
25*27162e4eSAndroid Build Coastguard WorkerCLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined
26*27162e4eSAndroid Build Coastguard Workerinto `-b1e18i1`.
27*27162e4eSAndroid Build Coastguard Worker
28*27162e4eSAndroid Build Coastguard Worker
29*27162e4eSAndroid Build Coastguard Worker#### The example of usage of static and dynamic LZ4 libraries with gcc/MinGW
30*27162e4eSAndroid Build Coastguard Worker
31*27162e4eSAndroid Build Coastguard WorkerUse `cd example` and `make` to build `fullbench-dll` and `fullbench-lib`.
32*27162e4eSAndroid Build Coastguard Worker`fullbench-dll` uses a dynamic LZ4 library from the `dll` directory.
33*27162e4eSAndroid Build Coastguard Worker`fullbench-lib` uses a static LZ4 library from the `lib` directory.
34*27162e4eSAndroid Build Coastguard Worker
35*27162e4eSAndroid Build Coastguard Worker
36*27162e4eSAndroid Build Coastguard Worker#### Using LZ4 DLL with gcc/MinGW
37*27162e4eSAndroid Build Coastguard Worker
38*27162e4eSAndroid Build Coastguard WorkerThe header files from `include\` and the dynamic library `dll\msys-lz4-1.dll`
39*27162e4eSAndroid Build Coastguard Workerare required to compile a project using gcc/MinGW.
40*27162e4eSAndroid Build Coastguard WorkerThe dynamic library has to be added to linking options.
41*27162e4eSAndroid Build Coastguard WorkerIt means that if a project that uses LZ4 consists of a single `test-dll.c`
42*27162e4eSAndroid Build Coastguard Workerfile it should be linked with `dll\msys-lz4-1.dll`. For example:
43*27162e4eSAndroid Build Coastguard Worker```
44*27162e4eSAndroid Build Coastguard Worker    gcc $(CFLAGS) -Iinclude\ test-dll.c -o test-dll dll\msys-lz4-1.dll
45*27162e4eSAndroid Build Coastguard Worker```
46*27162e4eSAndroid Build Coastguard WorkerThe compiled executable will require LZ4 DLL which is available at `dll\msys-lz4-1.dll`.
47*27162e4eSAndroid Build Coastguard Worker
48*27162e4eSAndroid Build Coastguard Worker
49*27162e4eSAndroid Build Coastguard Worker#### The example of usage of static and dynamic LZ4 libraries with Visual C++
50*27162e4eSAndroid Build Coastguard Worker
51*27162e4eSAndroid Build Coastguard WorkerOpen `example\fullbench-dll.sln` to compile `fullbench-dll` that uses a
52*27162e4eSAndroid Build Coastguard Workerdynamic LZ4 library from the `dll` directory. The solution works with Visual C++
53*27162e4eSAndroid Build Coastguard Worker2010 or newer. When one will open the solution with Visual C++ newer than 2010
54*27162e4eSAndroid Build Coastguard Workerthen the solution will be upgraded to the current version.
55*27162e4eSAndroid Build Coastguard Worker
56*27162e4eSAndroid Build Coastguard Worker
57*27162e4eSAndroid Build Coastguard Worker#### Using LZ4 DLL with Visual C++
58*27162e4eSAndroid Build Coastguard Worker
59*27162e4eSAndroid Build Coastguard WorkerThe header files from `include\` and the import library `dll\liblz4.dll.a`
60*27162e4eSAndroid Build Coastguard Workerare required to compile a project using Visual C++.
61*27162e4eSAndroid Build Coastguard Worker
62*27162e4eSAndroid Build Coastguard Worker1. The header files should be added to `Additional Include Directories` that can
63*27162e4eSAndroid Build Coastguard Worker   be found in project properties `C/C++` then `General`.
64*27162e4eSAndroid Build Coastguard Worker2. The import library has to be added to `Additional Dependencies` that can
65*27162e4eSAndroid Build Coastguard Worker   be found in project properties `Linker` then `Input`.
66*27162e4eSAndroid Build Coastguard Worker   If one will provide only the name `liblz4.dll.a` without a full path to the library
67*27162e4eSAndroid Build Coastguard Worker   the directory has to be added to `Linker\General\Additional Library Directories`.
68*27162e4eSAndroid Build Coastguard Worker
69*27162e4eSAndroid Build Coastguard WorkerThe compiled executable will require LZ4 DLL which is available at `dll\msys-lz4-1.dll`.
70