Monday, October 17, 2011

Compiling Zip and Unzip with MinGW

The current version of zip supports higher compression with the bzip2 method. To build zip with bzip2 compression using MinGW, first prepare the bzip2 library:



tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make
cp bzlib.h /mingw/include/
cp libbz2.a /mingw/lib


Then, get the zip source. Use the LOCAL_ZIP environment variable to configure zip.



export LOCAL_ZIP='-DLARGE_FILE_SUPPORT -DZIP64_SUPPORT -DUNICODE_SUPPORT -DBZIP2_SUPPORT -DALLOW_REGEX


Edit the LIBS line in the file makefile.gcc in the win32 folder to link zip with bzip2 library



LIBS=-luser32 -ladvapi32 -lbz2


Compile zip.



make -f win32/makefile.gcc


You'll find zip.exe in the source folder.



Compiling Unzip with MinGW



Unzip is a command-line extraction tool for .zip archives. In order to be able to unpack bzipped .ZIP archive, I need to compile unzip with bzip2 support. After compiling bzip2 as above, I downloaded unzip60.tar.gz from Info-Zip project at Sourceforge and unpacked it.



tar xzvf unzip60.tar.gz
cd unzip60


I fixed the file win32/Makefile.gcc in the section following "# optional inclusion of bzip2 decompression"



INC_BZ2LIB = -I/mingw/include
LOCFLAGS = -I/mingw/include -DUSE_BZIP2
LD_BZ2LIB = -L/mingw/lib -lbz2
LIBBZIP2 = /mingw/lib/libbz2.a


Then, I compiled Unzip like this:


make -f win32/Makefile.gcc
ls -l *.exe

Three executables unzip.exe, unzipsfx.exe and funzip.exe are created. Copy them to a folder in your path or /bin.


cp -iv *.exe /C/Windows


Usage Examples


To back up a folder:


zip -Z bzip2 -b C:\Windows\Temp -SDurX backup.zip *

About This Blog

KBlog logo This blog is about current events and issues concerning general population. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

icon
Powered By Blogger