Skip to content

Instantly share code, notes, and snippets.

@c-yan
Created May 29, 2018 13:59
Show Gist options
  • Save c-yan/f12223a600e611271d88058bfd628704 to your computer and use it in GitHub Desktop.
Save c-yan/f12223a600e611271d88058bfd628704 to your computer and use it in GitHub Desktop.
Compile zlib with mingw
Microsoft Windows [Version 10.0.17134.48]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\zlib-1.2.11>SET PATH=C:\MinGW\bin;%PATH%
C:\zlib-1.2.11>gcc -v
Reading specs from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5 (mingw-vista special r3)
C:\zlib-1.2.11>mingw32-make -fwin32/Makefile.gcc
gcc -O3 -Wall -c -o adler32.o adler32.c
gcc -O3 -Wall -c -o compress.o compress.c
gcc -O3 -Wall -c -o crc32.o crc32.c
gcc -O3 -Wall -c -o deflate.o deflate.c
gcc -O3 -Wall -c -o gzclose.o gzclose.c
gcc -O3 -Wall -c -o gzlib.o gzlib.c
gcc -O3 -Wall -c -o gzread.o gzread.c
gcc -O3 -Wall -c -o gzwrite.o gzwrite.c
gcc -O3 -Wall -c -o infback.o infback.c
gcc -O3 -Wall -c -o inffast.o inffast.c
gcc -O3 -Wall -c -o inflate.o inflate.c
gcc -O3 -Wall -c -o inftrees.o inftrees.c
gcc -O3 -Wall -c -o trees.o trees.c
gcc -O3 -Wall -c -o uncompr.o uncompr.c
gcc -O3 -Wall -c -o zutil.o zutil.c
ar rcs libz.a adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
windres --define GCC_WINDRES -o zlibrc.o win32/zlib1.rc
gcc -shared -Wl,--out-implib,libz.dll.a \
-o zlib1.dll win32/zlib.def adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o zlibrc.o
Creating library file: libz.dll.a
strip zlib1.dll
gcc -O3 -Wall -I. -c -o example.o test/example.c
gcc -o example.exe example.o libz.a
strip example.exe
gcc -O3 -Wall -I. -c -o minigzip.o test/minigzip.c
gcc -o minigzip.exe minigzip.o libz.a
strip minigzip.exe
gcc -o example_d.exe example.o libz.dll.a
strip example_d.exe
gcc -o minigzip_d.exe minigzip.o libz.dll.a
strip minigzip_d.exe
C:\zlib-1.2.11>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment