I just finished porting pigz from Unix to Windows (you can download pre-compiled binaries ). This article describes how I did it.
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.
Porting pthreads
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.
Porting dirent
Another Unix-only API that pigz uses is dirent.h , for reading the content of directories. I was lucky again: someone created a Windows port of dirent APIs
Misc fixes
There are few functions that pigz uses that are present in Visual Studio’s C library, but under a different name (e.g. stat is _stat , fstat is _fstat etc.). This is easily fixed with a #define .
Visual C doesn’t define ssize_t and PATH_MAX . A typedef here, a #define there solves those problems.
... continue reading