Ghostscript Overview. Ghostscript is an interpreter for the PostScript® language and PDF files. It is available under either the GNU GPL Affero license or licensed for commercial use from Artifex Software, Inc.It has been under active development for over 30 years and has been ported to several different systems during this time.
Table of contents
For other information, see the Ghostscriptoverview and the instructions on how to install Ghostscript.
- ImageMagick depends on Ghostscript fonts. To install them, type: brew install ghostscript. The brew command downloads ImageMagick and many of its delegate libraries (e.g. JPEG, PNG, Freetype, etc.) and configures, builds, and installs ImageMagick automagically. Alternatively, you can download the ImageMagick Mac OS X distribution we provide.
- This encapsulates the ghostscript engine so that other applications can use its. Free Artifex Software Mac/OS Classic Version 8.54 Full Specs. Download Now Secure Download.
General overview
This document describes how to build a Ghostscript executable from sourcecode. There are four major steps to building Ghostscript:
- Acquire the compressed archive files of source code for Ghostscript.
- Unpack the archive files into the Ghostscript directory.
- Configure the build to match your system and desired configuration options.
- Invoke '
make
' to build the software.
The remainder of this document describes each of these steps in detail.Note that some of this process is platform-dependent. After buildingGhostscript you must then install it; for that, see theinstallation instructions.
Long term users of Ghostscript may notice the instructions for a number ofolder systems have been removed from this document. There is no value judgmentimplied in this, but recognition that the build system has changed considerablyin recent years, and several of these legacy systems are no longer easilyavailable to the development team. We will always consider contributions tocontinue support for legacy systems.
How to acquire the source code
Building Ghostscript requires the Ghostscript source code itself, and insome cases the source code for the third-party libraries thatGhostscript uses.
Official releases can be found under the AGPL license at
http://ghostscript.com/download/
Ghostscript source code is packaged in gzip-compressed tar archives (*
.tar.gz
).(Unlike earlier versions, Ghostscript packages are now one, complete archive, including font filesand third party library dependency sources).ghostscript-
#.##.tar.gz
('#.##' are version numbers.)Software to decompress and extract both formats is available for almostevery platform for which Ghostscript is available -- including Unix, Linux,MS Windows, and so on -- but it's up to you to locate that software.See the section on unpacking the source code.
How to acquire the development source code
The Ghostscript team use git for versioncontrol.
If you require a snapshot of the development code, the easiest way to get itis to visit the web interface to our
git
repository:ghostpdl.gitand click the 'snapshot
' link next to the specific commitin which you are interested. After a short delay, that will download a completesource tree for the given commit in a gzipped
tar
archive.If you require access to several commits, or wish to regularly access thelatest development code, you are better to clone the entire
git
repository, using:git clone git://git.ghostscript.com/ghostpdl.git
which will create a local, read-only repository.
Both the '
snapshot
' and the git clone
methodsdownload the Ghostscript
sources as part of the GhostPDL
source tree, which includes the PCL/PXL
and XPS
interpreters also built on top of the Ghostscript
graphics library.The
configure
script discussed later in the document is created aspart of the Ghostscript
release process, and as the source treeretrieved from git
is 'pre-release' code, it does notinclude a pre-made configure
script. See autogen.shHow to unpack the source code
Unfortunately, there are no generally accepted standards for how to packagesource code into archives, so the instructions for unpacking Ghostscript arelonger than they should be. We begin with a brief explanation of how toextract the two kinds of archive files.
How to unpack compressed tar files generally
Tar (
.tar
) files are the de facto standard forarchiving files on Unix (every Unix-like system has the tar
program), and programs to extract their contents are also widely availablefor MS Windows, and most other environments. To economize on space and downloadingtime, Ghostscript's tar files are compressed with GNU gzip
, whichadds the suffix '.gz
' to the file name, giving'.tar.gz
'.To unpack a compressed tar file
MyArchive.tar.gz
youmust both decompress it and extract the contents. You can do this in twosteps, one to decompress the file and another to unpack it:gzip -d MyArchive.tar.gz
tar -xf MyArchive.tar
or in a pipeline:
gzip -d -c MyArchive.tar.gz | tar -xf -
or, if you have a program like GNU
tar
that can handlecompressed tar files, with a single command:tar -zxf MyArchive.tar.gz
The
tar
program automatically preserves directory structurein extracting files. The Ghostscript source archive puts all files under adirectory ghostscript-
#.##, so using tar
to unpack acompressed archive should always properly create that directory, which wewill call the 'ghostscript directory'. Make sure you're positioned in theparent of the ghostscript directory before unpackingthe files. If a subdirectory doesn't already exist, tar
creates it.Some other programs – under MS Windows, for instance – can also unpackcompressed tar files, but they may not automatically preserve directorystructure nor even extract files into the current directory. If you useone of these, you must
- set the program's options to 'Use folder names' or the equivalent, and
- check that it is extracting files into the right place.
As both
tar
and gzip
formats are now well supportedby several applications on MS Windows, we only supply the tar.gz
archive.are respectively a commercial and two free applications which can decompress and extract
.tar.gz
archives on MS Windows.How to unpack Ghostscript itself
At this point you have acquired the source codeand are ready to unpack it according to the preceding guidelines. To unpack the Ghostscriptsource, make the parent of the (new) gs directory the current directory.
2-step: | gzip -d ghostscript- #.##.tar.gz tar -xf ghostscript- #.##.tar |
---|---|
Pipe: | gzip -d -c ghostscript- #.##.tar.gz | tar -xf - |
GNU tar: | tar -zxf ghostscript- #.##.tar.gz |
All the Ghostscript source files are now in subdirectories of the gsdirectory.
Ghostscript Core Source subdirectories | ||||
---|---|---|---|---|
Subdirectory | Contents | |||
arch/ | Pre-defined architecture header files | |||
base/ | Graphics library C source code and makefiles | |||
contrib/ | Community contributed/supported output devices | |||
devices/ | The output devices supported by the Ghostscript team | |||
psi/ | PS interpreter C source code and makefiles | |||
Resource/ | Postscript initialization, resource and font files | |||
lib/ | PostScript utilities and scripts used with Ghostscript | |||
doc/ | Documentation | |||
man/ | Unix man pages | |||
examples/ | Sample PostScript files | |||
iccprofiles/ | Default set of ICC profiles | |||
windows/ | Visual Studio for Windows specific project and solution files | |||
toolbin/ | Useful (non-Postscript) tools, mostly for developer use only |
Optionally, if you downloaded the GhostPDL archive, you may also have:
Additional GhostPDL source subdirectories | ||||
---|---|---|---|---|
Subdirectory | Contents | |||
pcl/ | PCL/PXL interpreter C source code, makefiles, fonts etc | |||
xps/ | XPS interpreter C source code and makefiles |
Supporting third party libraries will also be in their own sub-directories (e.g.
jpeg
, freetype
and so on).Luratech compressor libraries
Ghostscript has optional support for the Luratech proprietary JBIG2and JPEG 2000 implementations. If you have the source code for theseand wish the compile them into Ghostscript, the build system expectsthem to be in directories named
luratech/ldf_jb2
andluratech/lwf_jp2
in the top level gs source directory, alongsidethe other third-party libraries. With the Luratech source directories in theexpected place, the build system will automatically include them.If you have the Luratech code but wish to build without it, on 'configure'based builds you can achieve this by doing:
./configure --without-luratech
On Windows, you can achieve it by adding:
NO_LURATECH=1
Ghostscript Mac Os X Sierra
to your nmake command line.With either of these options, the build will fall back to the defaults forboth JBIG2 and JPEG2000 decoding.
How to check for post-release bug fixes
Bug information and fixes are tracked on Ghostscript Bugzilla.For more information, please visit
http://bugs.ghostscript.com
How to prepare the makefiles
The Ghostscript makefiles are very large and complex in order to deal withthe diverse requirements of all the different systems where they may beused.
Ghostscript has an automatic configuration script. If you're on unix ora system that supports unix shell scripts, this is the easiest option to use.Simply type:
./configure
from the top level of the ghostscript source directory. It should configureitself based on what's available on your system, warn you of any missingdependencies, and generate a Makefile. At this point you can skip to thesection invoking make below. Also, many commonconfiguration options (like install location) can be set through optionsto the configure script.
Type '
./configure --help
' for a completelisting. Note that the configuration option is only available with theunix .tar distributions of the source.Note that if you're building Ghostscript from development source out ofa repository instead of from a released source package, you should run'
./autogen.sh
' instead of ./configure.
This scripttakes all the same options that configure does.If your system doesn't support the configure script or you don't wish touse it, you can use the traditional ghostscript makefile system, editingthe options by hand to match your system as described below.Fortunately, the only makefiles you're likely to want to change arerelatively small ones containing platform-specific information.
Platform-specific makefiles | ||
---|---|---|
Makefile | Used for | |
Makefile.in | Template makefile for the autoconf build | |
psi/msvc.mak | MS Windows with Microsoft Visual Studio 2003 and later. | |
base/unix-gcc.mak | Unix with gcc | |
base/unixansi.mak | Unix with ANSI C compilers other than gcc |
A number of platform indepdent makefiles in each of the core Ghostscript source directories.Since these files can change from one Ghostscript version to another, sometimessubstantially, and since they all include documentation for the variousoptions, here we don't duplicate most of that documentation: we recommendstrongly that you review the entire makefile specific for your operatingsystem and compiler before building Ghostscript.
Building against the Luratech compression libraries
To compile Ghostscript against the proprietary Luratech JBIG2 and JPEG2000 implementations, simply ensure that the
luratech/ldf_jb2
andluratech/lwf_jp2
containing the Luratech code exist in the top levelgs source directory, and (re-)run configure
(ensuring to make clean
beforere-running make). The configurescript will detect the presence of the directories, and apply the appropriatesettings in the Makefile.If you have the Luratech directories in place, but want Ghostscript builtwithout it, you can run configure with the
--without-luratech
option, andthe script will behave as if the directories did not exist.Changes for your environment
Assuming you have opted not to use the
configure
script orthe default Microsoft Visual Studio bulid, you mustedit the platform-specific makefile to change any of these:- The name of the makefile itself (
MAKEFILE
macro) - The locations to install Ghostscript files (
prefix
etc.) - The default search paths for the initialization and font files(
GS_LIB_DEFAULT
macro) - The debugging options (
DEBUG
andTDEBUG
macros) - Which optional features to include (
FEATURE_DEVS
) - Which device drivers to include (
DEVICE_DEVS
andDEVICE_DEVS
{1--20} macros) - Default resolution parameters for some printer drivers(
devs.mak
orcontrib.mak
, whichever definesthe driver)
In general these will be set to commonly sensible values already, butmay not be ideal for your specific case.
The platform-specific makefilesinclude comments describing all these except the
DEVICE_DEVS
options. These are described indevs.mak
and contrib.mak
, even though thefile that must be edited to select them is the platform-specific makefile.Some platform-specific options are described in the sections for individualplatforms. See the 'Options' section near the beginning of the relevantmakefile for more information.
Selecting features and devices
You may build Ghostscript with any of a variety of features and with anysubset of the available device drivers. The complete list of features isin a comment at the beginning of
gs.mak
, and the completelist of drivers in comments at the beginning of devs.mak
and contrib.mak
. To find what devices a platform-specificmakefile selects to include in the executable, look in it for all lines ofthe formFEATURE_DEVS=
{list of features}DEVICE_DEVS
*=
{list of devices}
For example, if the makefile has
FEATURE_DEVS=$(PSD)level2.dev
indicating that only the PostScript Level 2 facilities should be included,you might make it
FEATURE_DEVS=$(PSD)level2.dev $(PSD)pdf.dev
to add the ability to interpret PDF files. (In fact,
FEATURE_DEVS
in the current Unix makefiles already includes$(PSD)pdf.dev
.).It is extremely important that FEATURE_DEVS is set correctly. Currently,the default builds will include a complete feature set, and as such mostof those building Ghostscript will have no need to change it. Only thoseworking in heavily resource constrained environment will want to experiment,and it is vital that the implications of such changes be understood, otherwiseGhostscript may behave in unexpected or apparently incorrect ways, or mayeven fail to build.
The Unix makefile also defines
DEVICE_DEVS=$(DD)x11.dev
indicating that the X Windows driver should be included, but sinceplatform-specific makefiles as distributed normally include many of thepossible features and drivers, you will probably rather remove from themakefile the features and drivers you don't want. It does no harm toinclude unneeded features and devices, but the resulting executable will belarger than needed.
You may edit the
FEATURE_DEVS
line to select or omit any ofthe features listed near the beginning of gs.mak
, and theDEVICE_DEVS
* lines to select or omit any of the devicedrivers listed near the beginning of devs.mak
andcontrib.mak
. GS_DEV_DEFAULT is a string containing whitespaceseparate device names, and give the devices Ghostscript should attempt to use(and the order) if no device is specified on the command line;see the usage documentation for how toselect an output device at run time using the-sDEVICE=
switch. Ifyou can't fit all the devices on a single line, you may add lines definingDEVICE_DEVS1=$(DD)
{dev11}.dev
..$(DD)
{dev1n}.dev
DEVICE_DEVS2=$(DD)
{dev21}.dev
..$(DD)
{dev2n}.dev
etc., up to
DEVICE_DEVS15
. Don't use continuation lines --on some platforms they don't work.Note that if you want to include a driver named xxx, you must put
$(DD)
xxx.dev
inDEVICE_DEVS
*. Similarly, if you want to include a featurerelated to the PostScript or PDF language interpreters (PostScript level1 . 3, or other language features such as the ability to read EPSF files orTrueType font files), you must represent it as$(PSD)
xxx.dev
.Precompiled run-time data
Ghostscript normally reads a number of external data files at run time:initialization files containing PostScript code, fonts, and other resourcessuch as halftones. By changing options in the top-level makefile for theplatform, you can cause some of these files to be compiled into theexecutable: this simplifies installation, improvessecurity, may reduce memory requirements, and may be essential if you areplanning on putting Ghostscript into ROM. Compiling these files into the executablealso means the executable is (largely) self-contained, meaning initializationfiles, font files, resource files and ICC profile files are certain to be availableand accessible. In general, Ghostscript should initialize more quickly, and files(especially PDF) files making heavy use of the built-in fonts will interpret morequickly.
For those distributing Ghostscript binaries, compiling those files into the executablehas another implication, any site-specific customizations (such as font and CIDFontsubstitutions) are slightly more complex to implement - see:
How Ghostscript finds files
for how to influence where Ghostscript searches for files. Furthermore, if the filesGhostscript uses are also required to be accessible by applications other than Ghostscript(the mostly case for this would be font files and ICC profile files), having those filescompiled into Ghostscript maybe suboptimal, essentially require two copies of the filedata to be distributed (one set built into Ghostscript, and the other as 'normal' filesaccessible outside of Ghostscript.
Compiling the initialization files (
Resource/Init/gs_init.ps
, etc.)into the executable is the default. To disable this, change the 1
toa 0
in the lineCOMPILE_INITS=1
Or, if you use the
configure
based Unix-style build, you can disableCOMPILE_INITS by adding the option --disable-compile-inits
to the invocationof configure
Files are now compiled into the executable as a %rom% file system that canbe searched, opened, etc. as with the normal (%os%) file system. The datais (mostly) compressed. Several of the initialisation files (those in
Resource/Init
)are also converted to binary Postscript encoding, and 'merged' into a single monolithicfile - this is done for both size and speed optimization. Files that are often customized forindividual installations (such as Fontmap
and cidfmap
) are notmerged into the single file and thus installation specific versions can be used.The set of files built into the %rom% file systemis specified in the
psi/psromfs.mak
file. By default the setof files built into the rom file system comprises all the resource filesGhostscript requires to run successfully (all the files under Resource
directory, and those under the iccprofiles
directory). Refer to the filebase/mkromfs.c
for a description of the parameters thatcontrol source and destination pathnames, file enumeration exclusion,compression, etc.Fonts normally are compiled into the executable using
mkromfs
(above) from the Resource/Font/ directory.Similarly, Halftone resources can be compiled into the executable using
mkromfs
, but also threshold-array halftones can be compiledinto the executable. See the 'Compiled halftone' section of int.mak
for a sample makefile fragment, genht.c
for the syntax ofhalftone data files, and lib/ht_ccsto.ps
for a sample data file. Note that even though the data files use PostScript syntax, compiled halftonesdo not require the PostScript interpreter and may be used with the graphicslibrary alone.Setting up 'makefile'
After going through the steps just described to unpackthe sources, configure the build and make any desiredchanges to the makefiles.As the final step in preparing to build Ghostscript you must usuallyassociate the name '
makefile
' with the correct makefilefor your environment so the make
command can find it.See the section on your particular platform for how to do that ifnecessary.On unix systems,
./configure
(or if checked out of git,./autogen.sh
) should create a Makefile
which worksin most scenarios. Manual tampering and editing should rarely be needednor recommended.Invoking 'make'
make
- Builds Ghostscript without debugging options.
make debug
- Builds Ghostscript with debugging options and additional internal errorchecks. The program will be somewhat larger and slower, but it will behaveno differently unless you actually turn on debugging options at executiontime with the
-DDEBUG
or-Z
command line switches described in the usage documentation.
make pg
- On Unix platforms, builds with the
-pg
compiler switch, creating an executable for time profiling.
make install
- After building, installs the Ghostscript executables, support files, and documentation, but does not install fonts. See the installation documentation.
make (debug)clean
- Deletes all the files created by the build process (relocatables, executables, and miscellaneous temporary files). If you've built an executable and want to save it, move it first to another place, because '
make clean
' deletes it. ?
make so
- On some platforms (Linux, *BSD, Darwin/Mac OS X, SunOS), it is possible to build ghostscript as a shared object library. There is a corresponding '
make soclean
' for cleaning up.
Note: on most platforms some of these simple instructions don'tquite work in one way or another. Read the section on your specificplatform.
Note 2: If you are attempting to build a statically linkedexecutable, you will probably need to add libraries to the linker options(libraries that are normally pulled-in automatically by the dynamic linker).These can be added at the make command line using the 'EXTRALIBS=' option.Unfortunately, the set of libraries that may be required varies greatlydepending on platform and configuration, so it is not practical to offera list here.
Cross-compiling
Cross-compiling is not fully supported by the
configure
script (suchsupport is a work-in-progress).You can either use
base/unixansi.mak
or unix-gcc.mak
as the basis for a cross-compile makefile, or use configure
tocreate a basic Makefile
as the basis. And modify to suit.You can set the compiler to your cross-compiler for
configure
by doing:./configure CC=<cross-compiler executable>
and
configure
will then run its checks (as best it can) with thecross-compiler.If you do so, you should also give
configure
the option to set thetarget architecture endianness: --enable-big-endian
or --enable-little-endian
.It would also be wise to review the settings shown in the output of
./configure --help
forany that would be applicable to your target.The Ghostscript build system uses several interim executables, built and run on the
host
,as such, even when cross-compiling, a host native
compiler is also required. You must edityour makefile
to ensure that is available. Find the line that starts:CCAUX=
and set that to your
host compiler
.If you did not use
configure
or did not set the CC
variable for configure
,you must also set the:CC=
to your cross-compiler.
The Ghostscript build system uses a utility called
genarch
(see base/genarch.c
for details) to interrogate the environment andgenerate a header file describing the architecture for which Ghostscript is beingbuilt. As this is run on the host
it will generate header for thehost architecture
rather than that of the target
.For cross compiling, you must create (or modify) a header file (
arch.h
)which accurately describes the target architecture
. Then you mustedit your makefile
by finding the line:TARGET_ARCH_FILE=
and set it to the path to, and file name of your custom
arch.h
file. With thatsetting, genarch
will still be run, but rather than interrogate the current environment,it will copy the contents of your custom arch.h
to the build.How to build Ghostscript from source (PC version)
All Ghostscript builds in PC (DOS and MS Windows) environments are 32- or64-bit: 16-bit builds are not supported. The relevant makefiles are
PC makefiles | ||||
---|---|---|---|---|
Makefile | Construction tools | For environment | ||
msvc.mak | Microsoft Visual Studio .NET 2003 (or later) | MS Windows 32/64-bit | ||
Makefile.in | Cygwin/gcc | Cygwin (Use Unix configure ) |
Ghostscript requires at least MS Windows 95 (although we no longer actively test norsupport Win95, we have not deliverately done anything to break compatibility with it).We recommend at least MS Windows NT 4.0.
For building, Ghostscript requires at least Visual Studio .NET 2003, and we recommendat least Visual Studio 2005 (required for 64 bit Windows support).
Note that the
make
program supplied with Visual Studio (and earlierVisual C++ versions) is actually called nmake
. We refer to thisprogram generically as make
everywhere else in this document.You must have
cmd.exe
in your path to build Ghostscript (usingthe Visual Studio command prompt is ideal). After making any changes required to choosefeatures and devices to build into the executable, you can then invoke make
to build the executable.Microsoft Visual Studio
Using Microsoft Visual Studio
The Ghostscript source distribution ships with
project
and solution
files for Visual Studio 2005 and later. These can be found in the windows
directory.The project(s)
are nmake projects
which means that rather than VisualStudio controlling the build directly, it delegates the build process the the nmake
.Addresses an issue that could cause battery to drain more quickly. Mac software update 10.10. Addresses an issue that could cause Reminders to sync slowly. Fixes an issue that could impact recognition of Siri requests on iPhone 11, iPhone 11 Pro and iPhone 11 Pro Max. Resolves a problem where Safari search suggestions may re-enable after turning them off.
Beyond lacking support for parallel builds (
nmake
cannot support parallel builds),there should be little visible difference between a conventional VS project and annmake project
to the user of the VS graphical interface. The only exception to thatis if you have to make changes to build options beyond those available in the defined buildconfigurations. In that case, you need to find the Nmake
tab in the projectProperty Pages
and modify the appropriate entry: Build Command Line
,Rebuild All Command Line
and/or Clean Command Line
.As mentioned above,
nmake
does not support parallel builds. If youhave downloaded and are building the GhostPDL
source archive (which containsGhostscript, GhostPCL, GhostXPS, and GhostPDL 'products'), the GhostPDL.sln
contains individual projects for each product but, as a result of the limitations of nmake
the products cannot be built in parallel, because nmake's
lack of parallel buildawareness means it cannot manage the dependencies shared between the products, and may fail as multiplebuilds attempt to access the same dependencies. To build all the products in one action, use the
All
'pseudo-project'. TheAll
project uses a single nmake
invocation to build all the supported products.NOTE: changing the
Output
property in the Nmake
properties will notchange the name of the executable - to do that requires editing of the psi/msvc.mak
makefile, or you can add: GS=myname.exe
to the nmake
command line.Using the command line
Ghostscript can be made using the Windows command prompt or one of the various commandline shells made for Windows, as long as the command line syntax is compatible with theWindows
CMD.exe
. The Visual Studio command prompt is ideal.In order for the makefiles to work properly, two items may have to be changed. An attempt is made to select the correct version of Microsoft Visual C++ based on the version of nmake. If this doesn't work it will default to version 6.x. If the auto-detection does not work, and you are not using version 6.x then before building, in
psimsvc.mak
find the line '#MSVC_VERSION=6
' and change it to 'MSVC_VERSION=4
', 'MSVC_VERSION=5
', 'MSVC_VERSION=7
' or 'MSVC_VERSION=8
' and so on. In some cases the location of the Microsoft Developer Studio, needs to be changed. The location of Microsoft Developer Studio is defined by the value of
DEVSTUDIO
. There are several different definitions of DEVSTUDIO
in psimsvc.mak. There is one for each of the currently supported versions of Microsoft Visual C++ (4, 5, 6, 7, 7.1 and 8). The normal installation process for Microsoft Visual C++ includes setting the location of the Microsoft Visual C++ executables (cl.exe, link.exe, nmake.exe, rc.exe) in your PATH definition and the LIB and INCLUDE environment variables are set to point to the Microsoft Visual C++ directories. If this is true then the value for
DEVSTUDIO
can be changed to empty. I.e. DEVSTUDIO=
If PATH, LIB, and INCLUDE are not correctly set then the value for
DEVSTUDIO
needs to be defined. For example, for version 6.0, the default definition for the location for the Microsoft Developer Studio is: DEVSTUDIO=C:Program FilesMicrosoft Visual Studio
If the path to Microsoft Developer Studio on your system differs from the default then change the appropriate definition of DEVSTUDIO
. (Remember that there is a separate definition of DEVSTUDIO
for each version of MSVC, so be sure to change the correct definition.) To run the
make
program, give the command nmake -f psimsvc.mak
Rather than changing psi/msvc.mak, these values can also be specified onthe make command line, I.e.
Gswin64c Exe Windows 10
nmake -f psimsvc.mak MSVC_VERSION=6 DEVSTUDIO='C:Program FilesMicrosoft Visual Studio'
nmake -f psimsvc.mak MSVC_VERSION=7 DEVSTUDIO='C:Program FilesMicrosoft Visual Studio .NET'
Note that double quotes have been added around the path for
DEVSTUDIO
due to the spaces in the path value.This command line can also be put into a batch file.
You may get warning messages during compilation about various undefinedand/or unsupported switches - this is because the compiler switches are setin the makefiles, and are applied when building with all versions of VisualStudio, but not all options are supported (or required) by all versions ofVisual Studio. These warnings are benign and can be ignored.
Building with the Luratech compression libraries
Install Ghostscript Windows 10
If you wish to compile Ghostscript with the Luratech JBIG2 and JPEG 2000implementations, the source should be installed in the top-leveldirectory of the Ghostscript source.If you have an appropriately licensed source distribution this shouldalready have been done.
With the Luratech source in the
luratech/ldf_jb2
andluratech/lwf_jp2
directories in the top level gs sourcedirectory, the nmake makefile will detect their presence, and use themautomatically.If you have the Luratech code in place, but wish Ghostsrcipt to be builtwithout the Luratech decoders, you can do so by passing NO_LURATECH=1 onthe nmake command line, or add the define to your Visual Studio project.
Microsoft Environment for 64-bit
Building Ghostscript for 64-bit Windows (AMD64 processor) requiresMicrosoft Visual Studio .NET 2005 or Microsoft Visual Studio 2008 or lateron 64-bit Windows. Cross compiling on 32-bit Windows is possible.
Compiling for 64-bit is similar to theMicrosoft Environment instructions above,but with the addition of a WIN64 define.
To make ghostscript use
nmake -f psi/msvc.mak WIN64=
Making self-extracting installers
You can build self-extracting Windows installers based on
NSIS (Nullsoft Scriptable Install System)
. To do so, use the nsis
makefile taget as well as any other options, for example: nmake -f psi/msvc.mak WIN64= nsis
will create an
nsis
based installer for Ghostscript built for 64 bit Windowssystems.Microsoft Environment for WinRT
Ghostscript can be built in the form of a win32 DLL for use within a Windows Runtimeapplication or Windows Runtime component. Building for WinRT requires use ofMicrosoft Visual Studio 2012. There is a solution file that can be loaded into VS 2012,in the directory
winrt
The WinRT application or component should include
iapi.h
fromgs/psi
and link with gsdll32metro.lib
fromgs/debugbin
or gs/releasebin
. Also any app usingghostscript either directly or via a component should add gsdll32metro.dll
as 'content'. This inclusion of the dll is necessary so that itwill be packaged with the app. If one wishes to be able to run the debugger onghostscript then gsdll32metro.pdb
should also be added as content.Cygwin32 gcc
It is possible to compile Ghostscript for MS Windows using the Cygwin32 gcc compiler,GNU
make
, using the 'configure' generated Makefile.Information about this compiler and environment is at the Cygwin site:
http://www.cygwin.com/
MSys/Mingw
The configure build can be used to build Ghostscript on MSys/Mingw systems,but with a caveat. The msys-dvlpr adds header files into the compiler's headersearch paths which cause a clash, and the build will fail as a result. If youhave the msys-dvlpr package installed, and until a better solution is availableyou can work around this by temporarily renaming the 'mingwmsys1.0include'directory so those headers are no longer found by the compiler.
How to build Ghostscript from source (MacOS version)
MacOS X
The unix source distribution (.tar.gz) builds fine on Darwin/MacOS X,albeit without a display device. You can generally just use the Makefilegenerated by configure as your top-level makefile and get a reasonable defaultbuild. This will allow you to use Ghostscript from the command line as a BSD-layertool to rasterize postscript and pdf to image files, and convert between thehigh-level formats supported by Ghostscript. See the instructions for theunix build below for details of how to customize this build.
NOTE: If you have MacPorts (http://www.macports.org/) installed, it can'confuse' the configure script because it includes some librares whichduplicate the 'system' ones. This can cause missing symbol link errors.In order to resolve this, you can do:
LDFLAGS='-L/usr/lib' ./configure
.That will force the linker to search the default directory first, and thus pickup the system libraries first.It is also possible to build 'universal binaries' for MacOS X, containing
i386
and x86_64
binaries in one file, using the Makefile
from configure
. This can be achieved by using the following invokation ofconfigure
./configure CC='gcc -arch i386 -arch x86_64 -arch ppc' CPP='gcc -E'
You can choose the combination of valid architectures (i386/x86_64/ppc) that yourequire.
The separate options for CC and CPP are required because some ofthe features used by configure to explore the capabilities of the preprocessorare not compatible with having multiple -arch options.
Building a shared library on MacOS X is the same as for other Unix-like systems, the'configure' step is done normally, and the 'so' target is given to the make invocation,thus:
make so
The only difference compared to other Unix-like systems is that on OS X the resultingshared library is created with the '.dylib' file name extension, instead of the moreusual '.so'.
How to build Ghostscript from source (Unix version)
Ghostscript now ships with a build system for unix-like operating systemsbased on GNU Autoconf. In general the following should work to configureand build Ghostscript:
or
for building ghostscript as a shared library.
Please report any problems with this method on your system as a bug.
On modern unix systems,
./configure
should create a Makefile
which worksin most scenarios. Manual tempering and editing should rarely be needednor recommended.Note that if you're building Ghostscript from development source out ofa repository instead of from a released source package, you should run'
./autogen.sh
' instead of ./configure.
This scripttakes all the same options that configure does.(deprecated; see Autoconf-based method above)For the convenience of those already familiar with Ghostscript, the old methodbased on hand-edited makefiles is still possible but no longer supported(and in many cases, simply do not work without substantialexpert manual-editing effort). It may also be helpful ingetting Ghostscript to build on very old platforms. The rest of this section deals exclusivelywith that older method and includes numerous pointers regarding legacy systems.
(deprecated; see Autoconf-based method above)Before issuing the
make
command to build Ghostscript, youhave to make some choices, for instance- which compiler to use;
- what features and devices to include;
- whether to use system libraries for PNG and zlib;
- and how to handle issues for your particular platform.
Be sure to check the sections on tool-, OS-, and hardware-specific issues for noteson your particular platform and compiler. In fact, that is thefirst place to check if you build Ghostscript and it crashes or produces obviously incorrect results.
make tools
You require a make tool which supports separate directories forthe derived objects (such as object files, executables and dynamically createdheader files) and the source files.
In general, GNU make is the recommended choice, and some features (such as thebuilding of the Linux/Unix shared library build ('make so') are only availablewith GNU make.
Other
make
implementations are known to work, but are not guaranteedto do so.GNU make
Current versions of GNU
make
have no problems buildingGhostscript.OS-specific issues
H-P RISC workstations
- HP-UX versions before 11.0 do not support POSIX threads. Set
SYNC=nosync
in the makefile before building. - Ghostscript builds on H-P machines with either GNU gcc or H-P'sANSI-capable
cc
. The minimal, non-ANSI-capablecc
that shiped with some basic HPUX system does notwork. Ifcc
on your system doesn't accept the-Aa
switch, then you need to get the fullcc
or gcc. - If you use H-P's compiler, be sure you have upgraded to a recentrelease. Many bizarre symptoms have been reported trying to buildGhostscript with older, buggier compilers, for example:
- The link step fails with a message about '
max
' not being defined. - The build succeeds, but the resulting executable fails to start up,with an error message like 'Initializing.. Unrecoverable error: typecheckin .registerencoding'.
- The build succeeds, but the resulting executable produces a blackbackground on the first page of output.
- It is reported that On HPUX 9.* you need at least compiler patchPHSS_5723 and dld.sl patch PHSS_5734 to build Ghostscript. (As of late1997, those patches are long obsolete; the current patches are compilerPHSS_10357 and dld.sl PHSS_11246. It is unknown whether currentGhostscript releases work with compiler/dld.sl versions older than these.)
- On HPUX 10.*, we don't know what combinations of compiler version andswitches work. It is reported that On HPUX 10.20, setting'
CC=c89
' and 'CFLAGS=+O3 $(XCFLAGS)
'works, contradicting the information in the next paragraph, but this may bedependent on the specific compiler version. - In either HPUX version, you need to set'
CC=cc -Aa
' (or use-Ae
if youprefer), and set'CFLAGS=-D_HPUX_SOURCE -O $(XCFLAGS)
'. Higherlevels of optimization than-O
may work depending on yourcompiler revision; some users have reported success with+O3
, some have not. - Some users have reported needing
-DNOSYSTIME
and-D_POSIX_SOURCE
inCFLAGS
, but recent testsdo not show these to be necessary. - If you use gcc, it's a good idea to have a recent release -- at thevery least 2.7.2.1 or later.You may be able to get a workingexecutable with an older gcc by removing
-O
fromCFLAGS
.
(see Autoconf-based method above)
IBM AIX
We recommend installing gcc and GNU make, and using the Autoconf-based method.
Other combinations are known to work, but are less well supported.
Recent veresions of Ghostscript can trigger a 'TOC overflow' error with some compilerson AIX. If this occurs, use the linker flag '-bbigtoc', which can either be added toyour configure options:
configure LDFLAGS='-Wl,-bbigtoc'
Or on the make command line:
make XLDFLAGS='-Wl,-bbigtoc'
Silicon Graphics
(see Autoconf-based method above)
Users have had a lot of problems with the MIPSpro compilers on SGI systems.We recommend using gcc. If you do choose to use the MIPSpro compiler,please read the following carefully.
- To make the optimizer allocate enough table space, set
- With the compiler shipped with Irix 5.2, use the
-ansi
option. - The SGI C compiler may produce warnings about 'Undefined the ANSI standardlibrary defined macro stdin/stdout/stderr'. To suppress these warnings, add'
-woff 608
' to the definition ofCFLAGS
. - The SGI C compiler shipped with Irix 6.1 and 6.2 will not compile
zlib/deflate.c
properly with optimization. Compile this fileseparately without-O
. - With IRIX 6.5.x and the MIPSpro 7.x compilers there have been reports aboutincorrect output and binaries that cause segmentation faults. Varioussolutions have been suggested and you may want to try them in this order,until you get a working binary:
- Compile
idict.c
andisave.c
separatelywithout optimization after doing a normal compile; then relink.e.g.: - Set
CFLAGS=
(no optimization). - Use only
-O2
. Compiler produces incorrect outputwith-O3
or '-Ofast=ip32 -show
'. - Irix 6.5.1m with MIPSpro compiler 7.2.1.1m, Irix 6.5.3m with MIPSprocompiler 7.2.1, and probably other 6.5x / 7.2x combinations requirecompiling with the
-o32
option. Compiling with the (default)-n32
option produces non-working executables.-O2
is OK (possibly except foridict.c
), butnot-O3
.
CFLAGS='-Olimit 2500'
(for older compilers)CFLAGS='-OPT:Olimit=2500'
(for newer compilers)MIPSpro compiler version 3.19 is 'older', and 7.1 is 'newer'; we aren'tsure at what point in between the latter syntax was introduced.
cc -OPT:Olimit=2500 -I. -I./obj -o ./obj/idict.o -c ./idict.c
cc -OPT:Olimit=2500 -I. -I./obj -o ./obj/isave.o -c ./isave.c
Oracle/Sun
see Autoconf-based method above)
- The Sun unbundled C compiler (SC1.0) doesn't compile Ghostscriptproperly with the
-fast
option: Ghostscript core-dumps inbuild_gs_font
. With that compiler use-g
,or use gcc instead. - The Sun version of
dbx
often gives up with an errormessage when trying to load Ghostscript. If this happens, use GNUgdb
instead. (gdb
is more reliable thandbx
in other ways as well.) - A bug in some versions of
zlib
results in an undefinedsymbolzmemcmp
when compiling with Sun cc. Use gccinstead.
Solaris
- Solaris 2.2 may require setting '
EXTRALIBS=-lsocket
'.Solaris 2.3 and later seem to require 'EXTRALIBS=-lnsl -lsocket -lposix4
'. - For Solaris 2.6 (and possibly some other versions), if you set
SHARE_LIBPNG=1
,SHARE_ZLIB=1
, orSHARE_JPEG=1
, you may need to set - Solaris 2.n uses
/usr/openwin/share/include
for the X11 libraries rather than/usr/local/X/include
. - Solaris 2.n typically has Type 1 fonts in
/usr/openwin/lib/X11/fonts/Type1/outline
. - For Solaris 2.
n
in the makefile you must changethe definition ofINSTALL
from 'install -c
' to'/usr/ucb/install -c
'. - You may need to set
XLIBDIR
to the directory that holdsthe X11 libraries, as for other SVR4 systems. Set-DSVR4
inCFLAGS
. - If you are using the SunPRO C compiler, don't use optimization level
-xO3
. On SPARC platforms the compiler hangs; on Intelplatforms the generated code is incorrect. With this compiler on Intel, donot use the-native
flag: floating point computationsbecome unacceptably inaccurate. You can use-xcg92
(SPARCV8) and-dalign
for better performance. - One user reported compiling from source on a Linux NFS mountedvolume failed. Compiling from a local volume was the workaround.
XLDFLAGS=-R /usr/local/
xxx/lib:/usr/local/lib
using the full path names of the relevant directories.
Other environments
Environments lacking multi-threading
All environments mentioned here by name have multi-threading capability.However, if your environment doesn't, you can remove all need formulti-threading by setting
SYNC=nosync
in the top-levelmakefile. Note that you will not be able to use any so-called 'async'drivers (drivers that overlap interpretation and rasterization) if you dothis. No such drivers are in the DEVICE_DEVS*
lists of anymakefile that we distribute.Plan 9
Use
unix-gcc.mak
, editing it to defineCC=ccGCFLAGS=-D_BSD_EXTENSION -DPlan9
You will also probably have to edit many path names.
How to build Ghostscript with UFST
Note: This section is only for customers who have a Monotype Imaging UFST license.Other users please skip this section.
Ghostscript sources do not include UFST sources. You need to obtain them separately.The Ghostscript distributed source include only some source modules that provide abridge to UFST. You will also need an additional, UFST specific makefile: contactGhostscript support for more information
If optioned in, the Ghostscript build system will build the UFST as part of the normalbulid process (previously, the UFST was required to be built separately).
To build Ghostscript with UFST, specify additional options for 'make':
UFST_BRIDGE=1
- forces the UFST bridge to build.
UFST_ROOT=path
- specifies the path to UFST root directory or folder.
UFST_CFLAGS=options
- specifies C compiler options for UFST library. Refer to UFST manual for information about them.
UFST_LIB_EXT=extension
- sets the file name extension for object libraries. You must use the appropriate one for your platform and linker.
An example for Unix/GCC :
UFST_BRIDGE=1 UFST_ROOT=./ufst UFST_CFLAGS=-DGCCx86 UFST_LIB_EXT=.a
Starting with Ghostscript 9.x (Summer 2010), the above options are convenientlyinserted in the
Makefile
with(this also automatically disable the freetype bridge):./configure --with-ufst=./ufst
For Windows/MSVC you need only specify UFST_ROOT.msvc.mak sets the other options automatically.
Copyright © 2000-2020 Artifex Software, Inc. All rights reserved.
This software is provided AS-IS with no warranty, either express orimplied.This software is distributed under license and may not be copied, modifiedor distributed except as expressly authorized under the terms of thatlicense. Refer to licensing information at https://www.artifex.comor contact Artifex Software, Inc., 1305 Grant Avenue - Suite 200,Novato, CA 94945, U.S.A., +1(415)492-9861, for further information.
Ghostscript version 9.53.0, 10 September 2020