This article introduces the method of compiling zlib source code under Cygwin, although this process is simple, there are still some places to be aware of.
Zlib Source:
http://www.zlib.net/
After the download, the decompression will generate zlib-1.2.8 this folder.
1. Compile the steps:
- First, create a folder and use the Configure command to specify the compilation results to this folder.
- Second, make
- Finally, make install
Of course, you can also merge the last two steps into make & makes install
2. In order to deepen the impression, the following is the practice process:
$ pwd/cygdrive/g/ -/zlib-1.2. 8[Email protected]/cygdrive/g/ -/zlib-1.2. 8$ lsadler32.c Contrib FAQ infback.c inftrees.h QNX watcom Zlib.hamiga crc32.c gzclose.c inffast.c make_vms.com README Win32 zlib.MapAS400 crc32.h gzguts.h inffast.h Makefile test zconf.h Zlib.pc.cmakeinChangeLog deflate.c gzlib.c inffixed.h makefile.in treebuild.xml zconf.h.cmakein zlib.pc.inCMakeLists.txt deflate.h GZREAD.C inflate.c msdos trees.c zconf.h.in zlib2ansicompress.c doc gzwrite.c Inflat E.h NintendoDS trees.h zlib. 3Zutil.cconfigure examples INDEX inftrees.c old uncompr.c zlib. 3. pdf Zutil.h[email Protected]/cygdrive/g/ -/zlib-1.2. 8$ mkdir mylibs[email protected]/cygdrive/g/ -/zlib-1.2. 8$ **chmod777Mylibs**[email protected]/cygdrive/g/ -/zlib-1.2. 8$./configure--prefix=/cygdrive/g/ -/zlib-1.2. 8/mylibschecking forGcc... Checking forShared Library Support ... No Shared library Support. BuildingStaticLibrary LIBZ.A version1.2. 8With GCC. Checking foroff64_t ... No.checking forFseeko ... Yes.checking forStrerror ... YES.MV: whether to overwrite"Zconf.h", ignoring permission mode0000(---------)? Ychecking forUnistd.h ... Yes.checking forStdarg.h ... Yes.checking whether to use Vs[n]printf() or S[n]printf()...usingVs[n]printf(). Checking forvsnprintf () in stdio.h ... Yes.checking for returnValue of vsnprintf () ... Yes.checking forAttribute (visibility) support ... No.[email protected]/cygdrive/g/ -/zlib-1.2. 8$ makegcc-o3-i.-c-o example.o test/example.cgcc-o3-c-o adler32.o adler32.cgcc-o3-c-o crc32.o crc32.cgcc- O3-c-o deflate.o deflate.cgcc-o3-c-o infback.o infback.cgcc-o3-c-o inffast.o inffast.cgcc-o3-c-O in FLATE.O inflate.cgcc-o3-c-o inftrees.o inftrees.cgcc-o3-c-o trees.o trees.cgcc-o3-c-o zutil.o zutil.cgcc -o3-c-o compress.o compress.cgcc-o3-c-o uncompr.o uncompr.cgcc-o3-c-o gzclose.o gzclose.cgcc-o3-c- o gzlib.o gzlib.cgcc-o3-c-o gzread.o gzread.cgcc-o3-c-o gzwrite.o gzwrite.car RC libz.a adler32.o crc32.o DEFL ATE.O infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.ogc C-o3-o example.exe example.o-l. libz.agcc-o3-i.-c-o MINIGZIP.O test/minigzip.cgcc-o3-o Minigzip.exe MINIGZIP.O -L. Libz.a[email protected]/cygdrive/g/ -/zlib-1.2. 8$ make INSTALLCP libz.a/cygdrive/g/ -/zlib-1.2. 8/mylibs/libchmod644/cygdrive/g/ -/zlib-1.2. 8/MYLIBS/LIB/LIBZ.ACP zlib. 3/cygdrive/g/ -/zlib-1.2. 8/mylibs/share/man/man3chmod644/cygdrive/g/ -/zlib-1.2. 8/mylibs/share/man/man3/zlib. 3CP zlib.pc/cygdrive/g/ -/zlib-1.2. 8/mylibs/lib/pkgconfigchmod644/cygdrive/g/ -/zlib-1.2. 8/MYLIBS/LIB/PKGCONFIG/ZLIB.PCCP Zlib.h zconf.h/cygdrive/g/ -/zlib-1.2. 8/mylibs/includechmod644/cygdrive/g/ -/zlib-1.2. 8/mylibs/include/zlib.h/cygdrive/g/ -/zlib-1.2. 8/mylibs/include/zconf.h[email protected]/cygdrive/g/ -/zlib-1.2. 8$ lsadler32.c crc32.h gzguts.h inffast.o minigzip.exe trees.o zlib.pcadler32.o crc32.o GZLIB.C inffixed.h minigzip.o uncompr.c zlib.pc.cmakeinamiga deflate.c gzlib.o Inflat e.c msdos uncompr.o zlib.pc.inas400 deflate.h gzread.c inflate.h mylibs wat COM zlib2ansichangelog deflate.o gzread.o inflate.o nintendods Win32 Zutil.ccmakel Ists.txt doc gzwrite.c inftrees.c old zconf.h zutil.hcompress.c example.exe Gzwrit E.O inftrees.h QNX zconf.h.cmakein zutil.ocompress.o example.o INDEX inftrees.o README Zconf.h.inconfigure examples infback.c libz.a test zlib. 3Configure.LogFAQ INFBACK.O make_vms.com treebuild.xml zlib. 3. Pdfcontrib gzclose.c inffast.c Makefile trees.c zlib.hcrc32.c gzclose.o inffast.h Mak Efile.in trees.h zlib.Map[Email protected]/cygdrive/g/ -/zlib-1.2. 8
The resulting file can be seen in the mylibs.
Note :
1. In this example, the last generated is the ZLIB.A static library, when referenced in the makefile, to write the path of this static library, otherwise, such as the Zlib.h header can not find errors.
2. In Mylibs's include, there is a header file Zlib.h, which can be referenced by an external program.
This article is here.
Cygwin compiled zlib source code