Get the App
SLTechnology News&Howtos  ›  Servers  › 

Primary application of zlib

Shulou Source: shulou.com Published: 2022-06-03 01:13:39 11月13日 Update

Download the latest code here. I downloaded zlib-1.2.5.tar.gz.

After decompressing, enter the zlib-1.2.5 folder, and then use the following command to generate the library file

. / configure

Make

Libz.a will be generated after that

Edit the following test code in this directory

# include#include#include#include "zlib.h" int main () {unsigned char uncomp_bytes; uLong uncomp_size;uLong return_code=0;unsigned char comp_bytes; uLong comp_size=100;strcpy (uncomp_bytes, "helloworld"); uncomp_size=strlen (uncomp_bytes); printf ("uncomp_size:%d\ n", uncomp_size) If ((return_code = compress ((Byte *) comp_bytes,&comp_size, (Byte *) uncomp_bytes,uncomp_size))! = Z_OK) {printf ("return code:%d\ n", return_code); exit (1);} printf ("comp_size:%d\ n", comp_size); uncomp_size=100 If ((return_code=uncompress ((Byte *) uncomp_bytes,&uncomp_size, (Byte *) comp_bytes,comp_size))! = Z_OK) {printf ("return code:%d\ n", return_code); exit (1);} printf ("uncomp_size:%d\ n", uncomp_size); printf ("% s\ n", uncomp_bytes); return 0;}

Use the command:

Gcc test.c-o test-lz

The output is as follows:

Uncomp_size:10comp_size:18uncomp_size:10helloworld

Tags: Code commands generation backward library files files folders directories results tests output applications Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB Redmi NVidia macOS