<< HOME >>    << The DRIVER >>

Compiling Ghostscript 6.0 with Lexmark 5xxx & 7xxx drivers

Automating compilation with a source RPM


This page discusses the use of the source RPM ghostscript-6.0-3.nosrc.rpm to compile Ghostscript 6.0, and to prepare a binary RPM for installation of gs and related files.

Because the source RPM, which this page documents, came into being on the back of a Ghostscript driver for the Lexmark 5000, there are some notes which are specific to that and related Lexmark printers.

A RedHat system is assumed, particularly when discussing the setup of printers after Ghostscript is installed.  However, the notes may be useful to anyone, irrespective of his printer type, who requires Ghostscript on an i386 system with a gcc compiler and RPM package management.  The only other such system that I am aware of is Mandrake, but I have been informed that there are a number of others.  Could users of such systems please inform me of differences from the organization of the RedHat rhs-printfilters system.


The source RPM file: ghostscript-6.0-3.nosrc.rpm
This is available here.

Ghostscript sources

These are available from the Obtaining Aladdin Ghostscript 6.0 site.

The GS sources themselves


The jpeg, zlib and libpng sources

[Optional] ftp://ftp.cs.wisc.edu/ghost/aladdin/gs600/ghostscript-6.0libpng.tar.gz

Post release Ghostscript patches

Post release patches are currently (Wed May 10 2000) in an uncertain condition.  Aladdin is in the process of moving its Ghostscript development effort onto SourceForge .  The sources are already in a CVS repository there, and the bug tracking is being moved into the SourceForge bug tracking system.  I don´t know if or how this will impact this procedure for updating the source with patches.

Post release patches to the sources are available at the Aladdin site here.  At the time of writing there were none, but this link should always be checked before building.


The Ghostscript standard fonts are in fact the URW fonts.  These are widely available, and are part of the standard Red Hat distributions

Supplementary fonts for GS are available as part of the normal Red Hat distribution.  The 5.10 fonts are perfectly adequate to the task.

[Conditional] Supporting RPMs

If you are installing the resulting binary RPM on a Red Hat system with the rhs-printfilters package installed, you will need printerdb-utils.

Linking problems

One persistent problem that has been reported is a linking failure against the Xt library.  This is reported during the compilation as
/usr/bin/ld: cannot find -lXt

I had no idea what is going on here, but I have received advice from Michal Jaegermann that the cause of this problem is the lack of the traditional link from /usr/X11 to /usr/X11R6.  Provision is made for this in the instructions below.

Disk space

You will need approx. 44Mb of disk space to hold the downloaded sources, unzip them, compile GS and build the RPM, including required and optional fonts.  Of this, 38Mb is in /usr and 6Mb in /var.

After build, installation and cleanup, the fonts require 4Mb, the RPMs 2Mb and the installation of Ghostscript itself, 6Mb.

Root access

To complete the build, you will need to be root unless you have a personal RPM construction area set up.  If you do, then you probably don't need any more help from me; otherwise, root you shall have to be.  To install the resulting binary RPM, you will have to be root.

[Optional] Valid signatures

It is always a good idea to check the signatures of packages you are installing.  Binary RPMs are usually signed as part of the build process, and can be checked by issuing
rpm --checksig <binary-rpm>
Source RPMs may be accompanied by a separate signature.

In order to check any of these signatures, you must have gpg or pgp installed (depending on which of these was used to sign the file, and what methods was employed), and you must have access to the public key of the signatory.  This is not the place for a discussion of these programs.

Signatures for the source RPM

Building it


This discussion assumes the root user, and the default RPM construction locations:


For Mandrake users, the equivalent directories are:



Setting up

Check for the X11 link.
# ls -ld /usr/X*
If there is no /usr/X11 link to /usr/X11R6, you must create it.
# cd /usr
# ln -s X11R6 X11
See if printerdb-utils is required.
# rpm -q rhs-printfilters
If installed, you will need to install printerdb-utils.
Download printerdb-utils to /usr/src/redhat/RPMS/i386
Install the RPM.
# cd /usr/src/redhat/RPMS/i386
# rpm -U printerdb-utils*
(that's an asterisk)
Retrieve the Ghostscript sources.
Download ghostscript source to /usr/src/redhat/SOURCES
Retrieve the jpeg and zlib sources.
Download jpeg source to /usr/src/redhat/SOURCES
Download zlib source to /usr/src/redhat/SOURCES
N.B.  This step should be optional, under the same conditions as for the libpng libraries, as follows.  When I attempted to compile wihtout the zlib sources, however, my build failed.
[Optional] Retrieve the libpng sources.
Download libpng source to /usr/src/redhat/SOURCES
N.B. If the libpng sources are not retrieved, a suitable version of the library must already be installed on your system.  If this is not the case, the attempt to build will be rejected.
Retrieve and install the source RPM.
Download ghostscript-6.0-3.nosrc.rpm source RPM to /usr/src/redhat/SRPMS
# cd /usr/src/redhat/SRPMS
# rpm -U ghostscript-6.0-3.nosrc.rpm
This will place the patches and ancilliary files in the SOURCES directory, and the spec file, gs6.0.spec, in the SPECS directory.  N.B. The patches just installed must stay in /usr/src/redhat/SOURCES.  They are not to be confused with any post-release patches from Ghostscript.
Obtain any post-release patches.
[Optional] Read /usr/src/redhat/SOURCES/gs6.0-patches.README. It will explain in detail how the patches are handled. In general, though, simply download or move the patches into the SOURCES/gs6.0-patches directory.
Create the patches directory.
# cd /usr/src/redhat/SOURCES
# mkdir gs6.0-patches
Examine http://www.cs.wisc.edu/~ghost/aladdin/relnotes/gs600/index.html for any post-release patches.  If any exist:-
Download post-release patches to /usr/src/redhat/SOURCES/gs6.0-patches


The spec file /usr/src/redhat/SPECS/gs6.0.spec controls the build.
# cd /usr/src/redhat/SPECS
Either: build with the Ghostscript default US letter PAPERSIZE:
# rpm -bb --clean --rmsource gs6.0.spec
Or: build with A4 as the default PAPERSIZE:
# A4=1 rpm -bb --clean --rmsource gs6.0.spec

Slow down

Now wait for the build to complete.  The expectation is that the build will go to completion from here.  It takes a while.  Get to know your family again.  Do the dishes.

At the end of this process, you will have a brand spanking new binary RPM of your very own:

Installing it


Before Ghostscript can be installed, a minimum set of fonts must be available.  These are the URW fonts.

Check whether the fonts are already on the system..
# rpm -q urw-fonts
If the package is installed, and its release is equal to or greater than 1.1-8, Ghostscript may be installed.
Retrieve and install the urw-fonts.
Download urw-fonts to /usr/src/redhat/RPMS/noarch
# cd /usr/src/redhat/RPMS/noarch
# rpm -U urw-fonts-1.1-9.noarch.rpm


Install your new RPM.
# cd /usr/src/redhat/RPMS/i386
# rpm -U ghostscript-6.0-3.i386.rpm
"But I already have 6.0."
Whether this is a problem or not will depend on the version number of the ghostscript that you have installed.  ghostscript-6.0-1.i386.rpm, either from an Aladdin source, or from the previous version of this package, should be OK to update (the -U option.)
However, if you have aready installed a binary rpm at this same or a later level (6.0-3), you should remove the existing version first.
# rpm -e --nodeps ghostscript
If you managed to get duplicate entries into the database, you will get an error message about multiple packages from the above command. In that case, check that you do indeed have duplicates.
# rpm -qa|grep ghost
If there are duplicates, issue the command,
# rpm -e --nodeps --allmatches ghostscript-6.0
When the deck is clear, try the update command (-U) again.

Problems with printerdb

(See also the discussion of printerdb below, under Setting Up Printers.)  Users with recent instances of /usr/lib/rhs/rhs-printfilters/printerdb have reported that the installation of the RPM fails in the post-install phase during the attempt to update the printerdb file using the perl script mod-printerdb.

Aside from a bug of mine, which is fixed in this release, the problems are with bad or suspect data in the printerdb file.  The script will report the error, along with the line in which it occurs, and the three preceding lines.  Errors seen so far include the misspelling of keywords like `Resolution', and leaving out the colon `:' after a keyword like `StartEntry'.  Such errors in the printerdb file will have to be corrected manually.  The mod-printerdb script can then be re-run after the file has been fixed.

In order to allow the installation to proceed when such errors are encountered, I am including a clean copy of the printerdb file, with the changes for the Lexmark printers, in this distribution.  If the attempt to edit printerdb fails, the original file will be renamed to printerdb.with.errors, and the clean file will be installed.  You can check on the problems with your original printerdb later by:

# cd /usr/lib/rhs/rhs-printfilters
then repeatedly executing
# mod-printerdb printerdb.with.errors
and correcting the error that is reported after each run

Optional fonts

You may optionally install the extra GS fonts.
Download ghostscript-fonts-5.10-3.noarch.rpm to /usr/src/redhat/RPMS/noarch
# cd /usr/src/redhat/RPMS/noarch
# rpm -U ghostscript-fonts-5.10-3.noarch.rpm

Setting up printers

The main tool for setting up printers in Red Hat linux is the Tcl/Tk script printtool.  It must be run as root.  Printtool makes use of three primary resources.

  1. /usr/lib/rhs/rhs-printfilters/printerdb
  2. /etc/printcap
  3. /usr/bin/gs


This file contains a decription of printers and their capabilities, keyed to Ghostscript.  Red Hat distributes printerdb with a comprehensive manifest of printer types supported by Ghostscript.  This is fine as long as your printer is supported; in the case of the Lexmark 5000, 5700 and 7000, there was no support.

This source RPM includes the third party drivers for all of those Lexmark printers.  In order that the drivers may in turn be acknowledged by printtool, the RPM arranges to insert definitions for the printers into printerdb when the RPM is installed.


/etc/printcap defines the underlying operating system view of the printers on the system.  lpr, which is the usual interface to the printing system for users and applications alike, recognizes printers through their definitions in /etc/printcap.  On Red Hat systems, all editing of /etc/printcap is done by printtool.

To get your newly-compiled Lexmark 5000 driver (say) to actually control a Lexmark 5000 printer, you must run printtool as the root user.

# printtool
Ignore initial error messages about being unable to print to Windows or Netware printers.
A subsidiary window - Add a Printer Entry - pops up for Printer Type, with Local Printer set by default.  I will only discuss local printing here.
An Info window pops up with the results of auto-probing the parallel port devices, /dev/lp0, /dev/lp1 and /dev/lp2.  If none of these devices is reported as Detected, you will not be able to do much local printing.  Generally, /dev/lp0 will be Detected.  Press [OK].
Another popup - Edit Local Printer Entry.
This lets you specify a name (or multiple names separated by a vertical bar), spool directory, file limit, printer device and filter.
Select a meaningful name for your printer.  I set up a separate printer queue (that's what we're doing here) for each mode of my printer.  So, for example, I have a default queue called lp with an alias of lx6. This supports my printer in colour at 600x600.  The lp queue is useful, because lpr invoked without a printer name will print to the queue lplxblk supports black only at 600x600.  I also have lx3 and lx3blk for 300x600 modes.
Spool Directory
By default, /var/spool/lpd/lpdN, where N starts at 0.  Change the last component (the lpdN) to be the same as the name (or the first name, if you have aliases) you gave the queue inthe step above.  E.g., queue lx3 has spool directory /var/spool/lpd/lx3.
File Limit
Leave the file limit alone.
Printer Device
This will default to the first device detected by the auto-probing (see above.)  Unless you know something that printtool doesn't know, leave it alone.
Input Filter [Select]
Press [Select].  Now it gets interesting.
A big-time popup - Configure Filter.
You get a swag of input fields here: Printer Type, Resolution, Paper Size, Color Depth/Uniprint Mode, Printing Options, Margins, and Extra GS Options.  There is also an information field; Driver Description.  The displayed defaults of most will depend on the selection from Printer Type.
Printer Type
Select your printer.
It's not there?  To appear in this list, a printer must
  1. be compiled into the current gs binary
    (We just went through all that!)
  2. have an entry in printerdb.
If you are installing a new Lexmark driver with this source RPM, the entry for the driver should have been placed in /usr/lib/rhs/rhs-printfilters/printerdb .  To check the gs binary, execute
# gs --help
and look in the list of Available devices.  Then execute
# less /usr/lib/rhs/rhs-printfilters/printerdb
and look for the matching entry.  In any case, if you have followed these steps and the printer has not shown up, report a bug.
Driver Description
Automatically tracks the selected printer.  Information relevant to the remaining fields may be published here.
Select one.
Paper Size
Select one.  Yes, I know we went through that in compiling, but select one anyway.
Color Depth/Uniprint Mode
Not relevant to Lexmark printers at this stage.
Printing Options
Check buttons.
Send EOF after job to eject page?
Usually leave unchecked.  If the last page of your print jobs does not emerge from the printer, try checking this.
Fix stair-stepping text?
Not relevant to Lexmark (or any other GDI or PS) printers.  Leave unchecked.
Fast text printing (non-PS printers only)?
Not relevant to Lexmark (or any other GDI or PS) printers.  Leave unchecked.
Radio buttons.  Pages per output page; default 1.  Obvious.
I generally leave these alone.
Extra GS Options
This is a critical field, especially for Lexmark drivers.  For Henryk Paluch's 7000 (and 5700-hp) drivers, this field MUST be clear.  For my 5000 driver, many options may be specified here.  See the Driver Description field.
When you're finished, press [OK] or [Cancel] to quit.
Edit a Printer Entry has the focus again now.
Suppress Headers
Leave checked.
Happy with all of the values?  Press [OK] or [Cancel] to quit.
You're back to the main Print Sytem Manager popup.  Try out your printer.
Highlight your printer.
Select Tests
Select Print Postscript test page
An Info popup lets you now the page is queued to the printer.  Press [OK]
The page should now print.  If it doesn't, well....
Select PrintTool
Select Quit

Lexmark: Set up control queue

In order to enable control functions on the Lexmark 5000 and related printers, a control queue must be set on the device to which a Lexmark printer is attached (normally /dev/lp0).

N.B. If there is more than one Lexmark printer on your system, you will have to make adjustments to the queue names, and to the installed printer management commands.  (See below.)

As root,
# printtool
Ignore initial errors about Windows or Netware printers.
Add a Printer Entry
Local Printer
Edit Local Printer Entry
Assuming that the Lexmark printer is attached to device /dev/lp0
lp0.raw|lx.control   (That's a vertical bar between the two.)
Spool Directory
Printer Device
Input Filter
Configure Filter
Highlight Text-only Printer
Edit Local Printer Entry
Select PrintTool
Select Quit

The commands headclean (1), headalign (1), showcartridges (1) and hidecartridges (1) can now be executed on the printer by non-root users.

Lexmark: Printer management commands

N.B. These commands are NOT defined for the photo cartridge

Expose the print cartridges by moving the print carriage to the left.  This enables the cartridges to be installed or changed.
Application: Lexmark 5xxx and 7xxx.
Hide the print cartridges by docking the print carriage.  This should be called after issuing showcartridges and changing a cartridge.
Application: Lexmark 5xxx and 7xxx.
Print the head alignment pattern.  This should be run whenever a cartridge is changed.  Four patterns are printed.
This pattern displays the relative horizontal alignment of the black and colour heads.  Use the best aligned number as the value for the AlignA argument to Ghostscript for the Lexmark 5000.
This pattern displays the relative vertical alignment of the black and color heads.&nsbp; Use the best aligned number as the value for the AlignB argument to Ghostscript for the Lexmark 5000.
This pattern displays the bi-directional alignment characteristics of the black cartridge.  Not used by the Ghostscript driver.
This pattern displays the bi-directional alignment characteristics of the colour cartridge.  Not used by the Ghostscript driver.
Application: Lexmark 5000.  Possibly others.
Prints ink-intensive patterns designed to clear clogged nozzles.
Application: Lexmark 5000.  Possibly others.

Good night, sweet Prince.  May flights of angels sing thee to thy rest.

Copyright © 2000 Peter Bernard West

<< HOME >>    << The DRIVER >>

Lord, to whom shall we go?
$Id: compileGS.html,v 1.15 2000-05-25 13:23:33+10 pbw Exp pbw $
$Name: Release_6!0-4 $
Last modified: Sat Mar 11 12:14:18 EST 2000

Sun Mar 12 2000