lunedì, marzo 03, 2008

Ghostscript without dependencies

Ghostscript is one of the most powerful Postscript/Pdf engine I have ever used. It can convert Ps to Pdf, Pdf to Ps, rasterize Pdf and Ps to Jpeg, Tiff, Bmp and so on.
But Ghostscript requires many files to run. When you install it, they are placed in the lib and resource folders (plus some fonts placed in the font folder). During the installation process, some entries are also placed in the registry (on Windows systems).
So, if you need to run Ghostscript on a machine, you need to install it.

There is a way to include all the needed file into the ghostscript dll: compile it using the option COMPILE_INITS=1. The resulting dll is bigger than the normal: 8.7 MB instead of 3.5 MB. It contains all the needed files. To run ghostsfcript you need only gswin32c.exe and gsdll32.dll.

I have compiled ghostscript 8.62 using Visual Studio 2005.

Donwload the source code from SourceForge and from the VS2005 command line, run:

nmake -f src\msvc32.mak DEVSTUDIO= COMPILE_INITS=1 MSVC_VERSION=8 GS_LIB_DEFAULT = "./lib/;./font;$(GSROOTDIR)/lib;$(AROOTDIR)/fonts"

UPDATE: AFAIK Ghostscript is compiled with COMPILE_INITS=1 starting from version 8.63. So, you don't need to compile it by yourself.