How to compile pdf2djvu under Windows

As of pdf2djvu 0.5, compilation under Cygwin is discouraged and not supported. Instead, it is possible to compile pdf2djvu natively with MinGW.

This document contains a detailed compilation instruction.

Development environment

Use the Automated MinGW Installer. to install MinGW. Do not select any additional components.

Create the C:\msys\1.0\src directory.

Install MSYS 1.0.10. The post-install process will ask for the directory where MinGW was installed to; enter C:/mingw. Answer yes to other questions.

Install the MSYS Developer Tool Kit.

Download:

into C:\msys\1.0\src.

In the MSYS console, execute the following commands:

cd /mingw
tar -xzf /src/gcc-part-core-*.tar.gz
tar -xzf /src/gcc-part-c++-*.tar.gz

Pre-compiled libraries

Create the C:\msys\1.0\local directory.

From the GTK+ Project download the following libraries:

Unpack all the zips into C:\msys\1.0\local.

Compilation

Download sources for the following packages:

Put all *.tar.gz files into C:\msys\1.0\src\.

In the MSYS console, execute the following commands:

export CC=gcc-sjlj
export CXX=g++-sjlj
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export CPATH=/usr/local/include
export LDFLAGS=-L/usr/local/lib/

cd /src
tar -xzf poppler-*.tar.gz
cd poppler-*
./configure --enable-xpdf-headers
make
make install

cd /src
tar -xzf djvulibre-*.tar.gz
cd djvulibre-*
./configure
make
make install

cd /src
tar -xzf pdf2djvu-*.tar.gz
cd pdf2djvu-*
./configure
echo '#undef DJVULIBRE_BIN_PATH' >> version.hh
echo '#define DJVULIBRE_BIN_PATH "."' >> version.hh
make

mkdir ~/pdf2djvu-dist/
cp *.exe ~/pdf2djvu-dist/
cd ~/pdf2djvu-dist/
cp -r /usr/local/etc .
cp /usr/local/bin/{djvm,djvused,bzz,csepdjvu,djvuextract,cjb2,c44,djvumake}.exe .
cp /usr/local/bin/{freetype*,iconv,jpeg*,libdjvulibre-*,libexpat,libfontconfig-*,libpoppler-*}.dll .
cp /mingw/bin/mingwm*.dll .
strip *.exe

A stand-alone pdf2djvu distribution is now ready in C:\msys\1.0\home\…\pdf2djvu-dist\.