# Compiling the GNOME Print library

## Name

Compiling the GNOME Print library -- How to compile libgnomeprint

## Building GNOME Print on UNIX-like systems

This chapter covers building and installing GNOME Print on UNIX and UNIX-like systems such as Linux.

Before we get into the details of how to compile GNOME Print, we should mention that in many cases, binary packages of GNOME Print prebuilt for your operating system will be available, either from your operating system vendor or from independent sources. If such a set of packages is available, installing it will get you programming wih GNOME Print much faster than building it yourself. In fact, you may well already have GNOME Print installed on your system already.

On UNIX-like systems GNOME Print uses the standard GNU build system, using autoconf for package configuration and resolving portability issues, automake for building makefiles that comply with the GNU Coding Standards, and libtool for building shared libraries on multiple platforms.

If you are building GNOME Print from the distributed source packages, then won't need these tools installed; the necessary pieces of the tools are already included in the source packages. But it's useful to know a bit about how packages that use these tools work. A source package is distributed as a `tar.gz` file which you unpack into a directory full of the source files as follows:

          tar xvfz libgnomeprint-2.0.0.tar.gz

In the toplevel of the directory that is created, there will be a shell script called `configure` which you then run to take the template makefiles called `Makefile.in` in the package and create makefiles customized for your operating system. The `configure` script can be passed various command line arguments to determine how the package is built and installed. The most commonly useful argument is the --prefix argument which determines where the package is installed. To install a package in `/opt/libgnomeprint` you would run configure as:

          ./configure --prefix=/opt/libgnomeprint

A full list of options can be found by running `configure` with the --help argument. In general, the defaults are right and should be trusted. After you've run `configure`, you then run the make command to build the package and install it.

          make
          make install

If you don't have permission to write to the directory you are installing in, you may have to change to root temporarily before running `make install`. Also, if you are installing in a system directory, on some systems (such as Linux), you will need to run ldconfig after `make install` so that the newly installed libraries will be found.

Several environment variables are useful to pass to set before running configure. `CPPFLAGS` contains options to pass to the C compiler, and is used to tell the compiler where to look for include files. The `LDFLAGS` variable is used in a similar fashion for the linker. Finally the `PKG_CONFIG_PATH` environment variable contains a search path that pkg-config (see below) uses when looking for for file describing how to compile programs using different libraries. If you were installing GNOME Print and it's dependencies into `/opt/libgnomeprint`, you might want to set these variables as:

          CPPFLAGS="-I/opt/libgnomeprint/include"
          LDFLAGS="-L/opt/libgnomeprint/lib"
          PKG_CONFIG_PATH="/opt/libgnomeprint/lib/pkgconfig"
          export CPPFLAGS LDFLAGS PKG_CONFIG_PATH

You may also need to set the `LD_LIBRARY_PATH` environment variable so the systems dynamic linker can find the newly installed libraries, and the `PATH` environment program so that utility binaries installed by the various libraries will be found.

          LD_LIBRARY_PATH="/opt/libgnomeprint/lib"
          PATH="/opt/libgnomeprint/bin:$PATH"
          export LD_LIBRARY_PATH PATH

## Dependencies

Before you can compile the GNOME Print, you need to have various other tools and libraries installed on your system. The two tools needed during the build process (as differentiated from the tools used in when creating GNOME Print mentioned above such as autoconf) are pkg-config and GNU make.

- pkg-config is a tool for tracking the compilation flags needed for libraries that is used by the GNOME Print library. (A small `.pc` text file is installed in a standard location that contains the compilation flags needed for the library along with version number information.)

- The GNOME Print makefiles will mostly work with different versions of make, however, there tends to be a few incompatibilities, so the GNOME Print team recommends installing GNU make if you don't already have it on your system and using it. (It may be called gmake rather than make.)

- The libart module. It is available from the GNOME FTP site.

- The libxml2 module. It is available from the GNOME FTP site.

- The libbonobo module. It's available from the GNOME FTP site.

- The GLib library provides core non-graphical functionality such as high level data types, Unicode manipulation, and a object and type system to C programs. It is available from the GTK+ FTP site.

- Pango is a library for internationalized text handling. It is available from the GTK+ FTP site.

- The libintl library from the GNU gettext package is needed if your system doesn't have the `gettext()` functionality for handling message translation databases.

## Building and testing GNOME Print

First make sure that you have the necessary dependencies installed: pkg-config, GNU make, libart, libxml2, libbonobo, glib, and, if necessary, libintl. To get detailed information about building these packages, see the documentation provided with the individual packages. On a Linux system, it's quite likely you'll have all of these installed already except for pkg-config.

Then build and install the GNOME Print library, follow the steps of `configure`, `make`, `make install` mentioned above. If you're lucky, this will all go smoothly, and you'll be ready to start compiling your own GNOME Print applications.

If the `configure` scripts fails or running make fails, look closely at the error messages printed; these will often provide useful information as to what went wrong. When `configure` fails, extra information, such as errors that a test compilation ran into, is found in the file `config.log`. Looking at the last couple of hundred lines in this file will frequently make clear what went wrong. If all else fails, you can ask for help on the gnome-print mailing list. See Mailing lists and bug reports(3)> for more information.

## Extra Configuration Options

In addition to the normal options, the configure script for the GNOME Print library supports a number of additional arguments.

configure [--with-omni-libdir=DIR] [--with-omni-includedir=DIR] [--enable-font-install=[yes|no]] [--with-html-dir=PATH] [--disable-gtk-doc | --enable-gtk-doc]

--with-omni-libdir=DIR. FIXME: Add information here.

--with-omni-includedir=DIR. FIXME: Add information here.

--with-html-dir=PATH. FIXME: Add information here.

--disable-gtk-doc and --enable-gtk-doc. The gtk-doc package is used to generate the reference documentation included with GNOME Print. By default support for gtk-doc is disabled because it requires various extra dependencies to be installed. If you have gtk-doc installed and are modifying GNOME Print, you may want to enable gtk-doc support by passing in --enable-gtk-doc. If not enabled, pre-generated HTML files distributed with GNOME Print will be installed.