标签:cygwin zlib zlib编译 编译zlib zlib源码
本文介绍在cygwin下编译zlib源码的方法步骤,这个过程虽然简单,但还是有一些需要注意的地方。
zlib源码下载地址:
下载后,解压就会生成zlib-1.2.8这种文件夹。
当然,也可以将最后两步合并为 make & make install
$ pwd
/cygdrive/g/2015/zlib-1.2.8
ranke@csdn /cygdrive/g/2015/zlib-1.2.8
$ ls
adler32.c contrib FAQ infback.c inftrees.h qnx watcom zlib.h
amiga crc32.c gzclose.c inffast.c make_vms.com README win32 zlib.map
as400 crc32.h gzguts.h inffast.h Makefile test zconf.h zlib.pc.cmakein
ChangeLog deflate.c gzlib.c inffixed.h Makefile.in treebuild.xml zconf.h.cmakein zlib.pc.in
CMakeLists.txt deflate.h gzread.c inflate.c msdos trees.c zconf.h.in zlib2ansi
compress.c doc gzwrite.c inflate.h nintendods trees.h zlib.3 zutil.c
configure examples INDEX inftrees.c old uncompr.c zlib.3.pdf zutil.h
ranke@csdn /cygdrive/g/2015/zlib-1.2.8
$ mkdir mylibs
ranke@csdn /cygdrive/g/2015/zlib-1.2.8
$ **chmod 777 mylibs**
ranke@csdn /cygdrive/g/2015/zlib-1.2.8
$ ./configure --prefix=/cygdrive/g/2015/zlib-1.2.8/mylibs
Checking for gcc...
Checking for shared library support...
No shared library support.
Building static library libz.a version 1.2.8 with gcc.
Checking for off64_t... No.
Checking for fseeko... Yes.
Checking for strerror... Yes.
mv:是否覆盖"zconf.h",而不理会权限模式0000 (---------)? y
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for attribute(visibility) support... No.
ranke@csdn /cygdrive/g/2015/zlib-1.2.8
$ make
gcc -O3 -I. -c -o example.o test/example.c
gcc -O3 -c -o adler32.o adler32.c
gcc -O3 -c -o crc32.o crc32.c
gcc -O3 -c -o deflate.o deflate.c
gcc -O3 -c -o infback.o infback.c
gcc -O3 -c -o inffast.o inffast.c
gcc -O3 -c -o inflate.o inflate.c
gcc -O3 -c -o inftrees.o inftrees.c
gcc -O3 -c -o trees.o trees.c
gcc -O3 -c -o zutil.o zutil.c
gcc -O3 -c -o compress.o compress.c
gcc -O3 -c -o uncompr.o uncompr.c
gcc -O3 -c -o gzclose.o gzclose.c
gcc -O3 -c -o gzlib.o gzlib.c
gcc -O3 -c -o gzread.o gzread.c
gcc -O3 -c -o gzwrite.o gzwrite.c
ar rc libz.a adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
gcc -O3 -o example.exe example.o -L. libz.a
gcc -O3 -I. -c -o minigzip.o test/minigzip.c
gcc -O3 -o minigzip.exe minigzip.o -L. libz.a
ranke@csdn /cygdrive/g/2015/zlib-1.2.8
$ make install
cp libz.a /cygdrive/g/2015/zlib-1.2.8/mylibs/lib
chmod 644 /cygdrive/g/2015/zlib-1.2.8/mylibs/lib/libz.a
cp zlib.3 /cygdrive/g/2015/zlib-1.2.8/mylibs/share/man/man3
chmod 644 /cygdrive/g/2015/zlib-1.2.8/mylibs/share/man/man3/zlib.3
cp zlib.pc /cygdrive/g/2015/zlib-1.2.8/mylibs/lib/pkgconfig
chmod 644 /cygdrive/g/2015/zlib-1.2.8/mylibs/lib/pkgconfig/zlib.pc
cp zlib.h zconf.h /cygdrive/g/2015/zlib-1.2.8/mylibs/include
chmod 644 /cygdrive/g/2015/zlib-1.2.8/mylibs/include/zlib.h /cygdrive/g/2015/zlib-1.2.8/mylibs/include/zconf.h
ranke@csdn /cygdrive/g/2015/zlib-1.2.8
$ ls
adler32.c crc32.h gzguts.h inffast.o minigzip.exe trees.o zlib.pc
adler32.o crc32.o gzlib.c inffixed.h minigzip.o uncompr.c zlib.pc.cmakein
amiga deflate.c gzlib.o inflate.c msdos uncompr.o zlib.pc.in
as400 deflate.h gzread.c inflate.h mylibs watcom zlib2ansi
ChangeLog deflate.o gzread.o inflate.o nintendods win32 zutil.c
CMakeLists.txt doc gzwrite.c inftrees.c old zconf.h zutil.h
compress.c example.exe gzwrite.o inftrees.h qnx zconf.h.cmakein zutil.o
compress.o example.o INDEX inftrees.o README zconf.h.in
configure examples infback.c libz.a test zlib.3
configure.log FAQ infback.o make_vms.com treebuild.xml zlib.3.pdf
contrib gzclose.c inffast.c Makefile trees.c zlib.h
crc32.c gzclose.o inffast.h Makefile.in trees.h zlib.map
ranke@csdn /cygdrive/g/2015/zlib-1.2.8
生成的文件可以在mylibs中看到。
注意:
1. 本例中,最后生成的是zlib.a静态库,在makefile中引用的时候,要写成这个静态库的路径,否则,会报诸如zlib.h头找不到的错误。
2. 在mylibs的include中,就有头文件zlib.h,这个头文件就可以被外部程序引用。
本篇就到这里。
标签:cygwin zlib zlib编译 编译zlib zlib源码
原文地址:http://blog.csdn.net/liranke/article/details/46333135