Pigz was clearly written with Unix in mind, with no thought given to cross-platform portability.
Thankfully, it’s a relatively simple, command-line program that sticks to using standard C library.
Pigz uses pthreads for threading. Porting pthreads code to Windows would be a nightmare. Lucky me: someone already did all the hard work and implemented pthreads APIs
on top of Windows API, in only 20.000 lines of code. It seems to Just Work.
There are few functions that pigz uses that are present in Visual Studio’s C library, but under a different name (e.g.
_fstat etc.). This is easily fixed with a
Visual C doesn’t define
typedef here, a
#define there solves those problems.
I consolidated all such fixes in a single wincompat.h
#includes some .h files that are only available under Unix. I used
#ifndef _WIN32 around those.
Pigz uses standard Unix build tools: gcc and make.
While there are ports of GNU make to Windows and gcc-based compilers that can generate windows binaries (mingw), most Windows developers prefer using Visual Studio IDE.
Creating Visual Studio project files from scratch is time consuming and annoying, especially when you want to support multiple versions of Visual Studio.
makes it easier. It’s a meta-build system: you write a text file
that defines the project, which files to compile, compilation flags etc. and premake generates Visual Studio files from that description.
Premake supports Visual Studio 2008 and 2010 (and 2012 supports 2010 project files via conversion).
As far as porting goes, this one was easy thanks to existing efforts that created compatibility shims for the hard parts.
Premake is an interesting tool that allows to save time creating and maintaining Visual Studio projects.