This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Building

External packages

The full build requires external libraries that you must obtain elsewhere. Most, if not all of these are optional, and configure will build graphviz with reduced functionality if an external library is not found. Newer versions of these libraries should be fine - if not, please let us know.

A list of these external libraries can be found on the Graphviz source download page.

Notes

  • GD (generic raster graphics driver for PNG, GIF, JPEG)
  • ZLIB (raster image compression) NB: Use ./configure -s to build shared libraries. (See notes in zlib-1.2.3/Makefile)

These libraries (either static or dynamic) and their interface header files must already be on your system. It's OK if you install your own copies of these packages, though you may need to tell make or configure where to find them. Run configure --help for details.

On most Linux distributions these packages are already installed or installable from packages included in the distribution. You might need to install some -devel packages to get the include header files. Also, some of these packages require other packages, so for sanity, you should use some automated install mechanism such as rpms or macports, or look for complete packages.

Abbreviated Build Instructions

The recommended method for building graphviz from a downloaded source package is the usual:

./configure
make
make install

If you are building from Git sources, then you must have recent versions of libtool, libltdl-dev, automake, and autoconf. Build with:

./autogen.sh
make
make install

autogen.sh accepts the same options as the configure script that it generates for subsequent use.

Detailed Build Instructions

The preferred image renderer is cairo, with support from pango for fonts. This handles various bitmap formats as well as svg, pdf and PostScript.

The generic raster driver is gd and it can be configured to generate GIF (no compression), PNG (lossless compression), JPEG (lossy compression), and wireless bitmap (WBMP) files. The compressors all need zlib. In the current build, we use a top-level config.h file that defines various symbols, such as:

  • HAVE_JPEG
  • HAVE_PNG

This file is typically generated by configure based on how you invoke it and what it finds on your system.

If you don't enable the gd based drivers, graphviz will still have the printf style drivers for PostScript and SVG. (However, even these benefit from better text size estimation via Freetype, when it is available.)

Build tools for Unix

Use configure generated by GNU autoconf. This comes with the source packages. This often works well on a vanilla Linux distribution with Tcl/Tk, freetype-devel and libjpeg already installed by root under /usr. It works OK with other versions of Unix, but some adjusting of command line arguments to configure may be needed. For Linux you can also just pick up the source tarball or RPMs here.

First, if you are using sources from Git, run ./autogen.sh to generate the configure script. If you are using sources from graphviz-<version>.tar.gz this autogen.sh step is not needed.

Next, run configure. For help on possible configure options, run:

./configure --help

For example, I use

./configure  --prefix=$HOME/arch/sgi.mips3 \
	--with-freetypeincludedir=$HOME/arch/$ARCH/include/freetype2 \
	--with-freetypelibdir=$HOME/arch/$ARCH/lib \
	--with-tcl=/usr/common/tcl8.3.3

Obviously you would change the pathnames to reflect your installation.

Note that the directory ${prefix}/include is automatically searched for headers, and ${prefix}/lib for libraries.

If you have problems with one or more of the optional script language bindings, they can be disabled with e.g. --disable-perl.

When configure is finished, it reports which optional packages were found and which Graphviz features are enabled. If some package or feature you expected is not shown as used, you may need to check the config.log file or configure.ac or configure files to see what went wrong. Usually, any problem can be resolved using environment variables or the command-line flags of configure.

Once configure has finished, complete the build with

gmake
gmake install

Build tools for win32

See separate build notes for Microsoft Windows.

With some persistence you can likely get Graphviz to build on UWIN or Cygwin installed on Microsoft Windows. You will still need various third-party packages to enable all the Graphviz drivers.

Unix platform-specific build notes

Apple Mac OS/X

Currently, Glen Low provides a full-featured port of Graphviz. Also, Ryan Schmidt maintains versions of Graphviz for macports.

We recommend using macports to install the desired third-party libraries. Once these have been installed, the standard build using configure and make works fine. The only caveat is that sometimes, an incompatible, non-GNU tool is picked up rather than the needed GNU version.

Compiling Smyrna for OS X, Snow Leopard (Amanda Stent)

Xcode:

First if you updated from Leopard you have to reinstall developer tools. No getting around it, I tried, you just have to do it.

Macports:

Then you have to uninstall and clean up the Macports ports, all of them. Take the opportunity to reinstall Macports itself. There are migration instructions on the web, but it's a little hairier than they make it out to be because some of the links (e.g. hs-ports) will not be there and you will have to get over those hurdles manually.

Briefly, to do a clean install of macports do:

sudo port -f uninstall installed
sudo port clean --work --archive all
and then new macports
and then sudo port install the things you need now
and possibly sudo port selfupdate and sudo port upgrade outdated at the end

Then you have to install all the tools needed for Smyrna, glut, glade, etc., and all their dependencies. This takes days.

Now macports doesn't do glut separately. It's sneaky because if you say install glut, something will happen, but actually glut now comes with mesa. This will mess up your head. (The real meat of glut is part of the mesa package - ed.)

Graphviz:

Then you get your graphviz and you configure with --with-smyrna. I used the following:

configure --with-smyrna --with-glutincludedir=/opt/local/var/macports/software/mesa/7.6.1_1+hw_render/opt/local/include --with-glutlibdir=/opt/local/var/macports/software/mesa/7.6.1_1+hw_render/opt/local/lib --prefix=/usr/local/share/graphviz

I use:

configure --with-smyrna --with-glutincludedir=/opt/local/include  --with-glutlibdir=/opt/local/lib

On the webs they say to use -framework commandline option to gcc; however I couldn't figure out how to make this work with the makefile and configure file for graphviz.

Now, I got to a certain point and it grumbled about permissions and refused to go any further. So you may have to chmod in the source directory.

And I got to the point where it was building gv_perl.cpp and it refused to go any further. I got around this eventually by changing the call to XS to XSPROTO, thus obviating the need for XSUB.h (what does it do for you? nothing!).

And then it said it was done but when I went to run it it wouldn't start due to some missing template.dot so then you make clean, and make install again because by now you are confused as well.

And then it should work!

By the way making by sneakily cd'ing into the macosx folder and using the makefile labeled with your OS does not work.

AIX

Matt Fago tells us that --enable-shared=no is required or the executables segfault after seemingly correct compiles. (Bug #421)

Solaris

Put /usr/ccs/bin in $PATH

HP-UX

The X11 package must include /usr/contrib/X11R6 as well as the base stuff. For some reason GNU autoconf doesn't seem to find X11 in this location so you may need to add the following to the ./configure line:

--with-Xawincludedir=/usr/contrib/X11R6/include --with-Xawlibdir=/usr/contrib/X11R6/lib

1 - Windows

For building on Windows:

(Graphviz versions ≥ 2.41)

First, in the root of the repository, perform git submodule update --init. This will download all submodules, which are mostly the dependencies for the Windows build. Next, add the windows\dependencies\graphviz-build-utilities directory to your PATH (and restart Visual Studio or the prompt with which you execute msbuild after that). This folder contains the tools Bison, Flex and others with versions that are tested. If all went right, the dependencies are now set up and you can build Graphviz.

(Graphviz versions ≥ 2.30)

The current build process for Windows using Visual Studio is fairly simple assuming all of the necessary files are available and have been put in the correct place. The build assumes you have installed binary versions of GTK 2.0 or later, Qt, and ltdl, and source versions of GTS and ann. Further instructions can be found in the Graphviz gitlab repository.

This whole process could and should be simplified. In particular, the 3rd-party software should not be stored in two places, and the Graphviz files that are made part of the release should come from the source package, and not be stored separately. In addition, the GTS and ANN build should be separate from the Graphviz build. As 3rd-party libraries, these should only be built when the source is updated.

(Graphviz versions ≥ 2.22)

We now build both Visual Studio and MinGW versions of Graphviz. In addition, the source package comes with project files for Visual Studio, so building from source should be fairly simple in either case.

  • The first step is to add the third-party libraries. These are listed here. This is most easily done by installing a Windows binary version of GTK 2.0 or later.
  • Next, download and unwrap the Graphviz source package, and copy over either the stable release or the development source package.

Let $ROOT be the root directory (folder) in which you stored the Graphviz source.

Building with Visual Studio

  1. Copy the file $ROOT/windows/config.h into $ROOT.
  2. Copy the folder $ROOT/windows/FEATURE into $ROOT.
  3. Start Visual Studio and read in $ROOT/graphviz.sln. There are project files for all of the parts of Graphviz.
  4. Modify the various settings for include file and library directories to find the third-party software.
  5. Modify the settings as to where you want the software installed.
  6. Build Graphviz.

Building with MinGW

  1. Install MinGW and Msys. This gives a mini GNU-like compile environment

  2. Set environment variables based on your machine, giving values to the first six below:

    export INSTALLROOT           # Root install directory
    export GTKDIR                # Root of GTK tree
    export FONTCONFIGINCLUDEDIR  # Path of fontconfig include dir
    export FONTCONFIGLIBDIR      # Path of fontconfig lib dir
    export FREETYPEINCLUDEDIR    # Path of freetype2 include dir
    export FREETYPELIBDIR        # Path of freetype2 lib dir
    
    export CFLAGS="-DGVDLL=1"
    export CPPFLAGS="-I$GTKDIR/include -I$GTKDIR/include/freetype2 "
    export LDFLAGS="-L$GTKDIR/lib -no-undefined"
    export FONTCONFIG_CFLAGS=-I$GTKDIR/include/
    export FONTCONFIG_LIBS="-L$FONTCONFIGLIBDIR -lfontconfig"
    export FREETYPE2_CFLAGS=-I$FREETYPEINCLUDEDIR
    export FREETYPE2_LIBS=-L$FREETYPELIBDIR
    export PKG_CONFIG=$GTKDIR/bin/pkg-config
    export PKG_CONFIG_PATH=$GTKDIR/lib/pkgconfig
    
    export PANGOFLAGS="--with-fontconfig --with-fontconfiglibdir=$FONTCONFIGLIBDIR --with-fontconfigincludedir=$FONTCONFIGINCLUDEDIR --with-pangocairo"
    
  3. Change directory to $ROOT and run configure:

    ./configure -C --prefix=$INSTALLROOT --without-gdk-pixbuf --with-mylibgd --disable-swig --without-x  --disable-tcl --without-ipsepcola --enable-shared --disable-static --with-freetype=$GTKDIR/lib --enable-ltdl $PANGOFLAGS --without-gtk --without-gtkgl
    

    When configure finishes, it lists all of the Graphviz features that have been enabled. If there are problems, you can check for errors in config.log. You may have to add or modify other flags and environment variables for configure to give you the settings you want. Run configure --help to see the allowed options and environment variables.

  4. Run make

  5. Run make install

These builds create a feature-full version of Graphviz. You can tailor them to your wants. This is fairly simple for MinGW: just remove or reset the flag of the option you don't want. For Visual Studio, you will probably need to reset some of the values in config.h and some of the compile-time options.


(2.21 >= Graphviz versions > 2.14)

To simplify our build process, especially as most Windows users only want a binary version of the software, the Graphviz build for Windows now uses uwin, an open-source Unix layer on top of Windows. In this environment, we can use essentially the same tools and process used on Unix. In particular, we do not have to maintain multiple build files.

To build Graphviz:

  • Install the third-party libraries. This is most easily done by installing a Windows binary version of GTK 2.0 or later.

  • Download the Graphviz source package, and copy over either the stable release graphviz-VERSION.tar.gz or the development source package graphviz-working.tar.gz.

  • Unwrap the package:

    You can use, for example,

    gunzip < graphviz-working.tar.gz | tar xf -
    

    Let $ROOT be the directory in which you stored the Graphviz source.

  • Configure the package for your system:

    cd $ROOT
    configure --disable-shared --enable-static --with-mylibgd --disable-swig --without-x --without-tclsh --with-codegens --disable-ltdl
    

    You will probably want to provide additional arguments to configure to indicate where you have installed GTK, where you want the results installed (--prefix) and which additional optional packages you want built. Run configure --help to see the available set of arguments.

  • Build Graphviz:

    make install
    

Presumably, a similar approach would work with Cygwin or MinGW. The following are some notes by Steve Roush describing how he made a static build of the libraries on MinGW.

  • Install MinGW and Msys. This gives a mini GNU-like compile environment that produces Windows-compatible results.

  • You may need to configure and build in Windows "Safe mode". Try ./configure in normal mode; if it dies with "fork" problems, use Safe mode.

  • Edit the "configure" file. after this line:

    DEFS=-DHAVE_CONFIG_H
    

    add these lines:

        case "$host_os" in
        mingw*)
        DEFS="$DEFS -DMSWIN32"
        ;;
        esac
    
  • run configure:

    ./configure  --enable-static=yes --enable-shared=no 
    --prefix=/usr/local/ --with-libgd=no --enable-ltdl=no --disable-swig  
    --disable-sharp --disable-guile --disable-io --disable-java 
    --disable-lua --disable-ocaml --disable-perl --disable-php 
    --disable-python --disable-ruby --disable-tcl
    
  • edit lib/Makefile

    replace these lines:

    SUBDIRS = cdt graph agraph gd pathplan agutil sfio vmalloc ast vpsc \
        circogen dotgen fdpgen neatogen twopigen common pack gvc \
        ingraphs expr
    

    with these lines:

    SUBDIRS = cdt graph agraph gd pathplan  vpsc \
        circogen dotgen fdpgen neatogen twopigen common pack gvc \
        ingraphs
    
    make  # builds most of "lib" (see Makefile changes), cmd/dot and cmd/tools - stops on cmd/gvpr
    make install
    

here is the command line I used to build simple.c, after adding a few lines based on https://mailman.research.att.com/pipermail/graphviz-interest/2006q2/003586.html

X=simple;gcc -v -I'/usr/local/include/graphviz' -I'/usr/local/include' 
-o $X -O $X.c  -L/usr/local/lib -L/usr/local/lib/graphviz -lgvc  -lgraph 
-lpathplan -lcdt -lgvplugin_core -lgvplugin_dot_layout 
-lgvplugin_neao_layout -lgvplugin_gd -lgvplugin_pango -lgvc -lpathplan

If you desire to build directly using Visual Studio or other non-Unix-based environment, you will need to derive the necessary information from the supplied Makefiles.


(2.14 >= Graphviz versions >= 2.3)

We build Graphviz on Windows using the MS Visual C++ 6.0 compiler only. The simplest way to build the software from source on Windows is as follows:

  1. Download the Windows source package.

  2. Unwrap the package:

    If you have Unix tools available, you can use

    gunzip < graphviz-win.tgz | tar xf -
    

    If not, double click on the file and WinZip should start up and let you store all of the files into a directory.

    Let $ROOT be the directory in which you stored the Graphviz source.

  3. Add the third-party libraries:

    1. zlib 1.1.3 http://www.gzip.org/zlib/
    2. libpng 1.0.6 http://www.libpng.org/pub/png
    3. jpeg-6b 62 http://www.ijg.org/
    4. freetype 2.1.7 http://freetype.sourceforge.net/
    5. expat http://expat.sourceforge.net/

    The versions should be at least the ones indicated. You can download the files from https://www.graphviz.org/Misc/third-party.zip. Unzip the package in the $ROOT directory; this will create a subdirectory called third-party. Or you can obtain the libraries yourself, and install them in $ROOT\third-party Also note that these libraries come with the binary release.

  4. Build the software in one of the following ways:

    • Run the script $ROOT\build.bat while in the $ROOT directory. You'll first want to check that the vc variable points to your local installation of visual C. Obviously, this should be run in a DOS command window.

    • The file $ROOT\ws\graphviz.dsw is the main workspace for the Graphviz libraries and graph drawing programs. The file $ROOT\ws\tools.dsw provides the workspace for the additional Graphviz tools. Double-clicking on these files will open the workspaces using the MS Visual Studio, from which you can use the Build menu item to create the various libraries and programs.

      Note that we have avoided all dependencies (i.e., there are no .dep files) because we found they tended to include absolute pathnames. If necessary, follow the order used in build.bat to be safe.

    • If you have a Unix environment, with a real ksh, run the script $ROOT\wmake.sh after setting the PATH, LIB and INCLUDE shell variables to the paths where the Visual C programs are installed on your machine, and the associated library and include file directories.

Once built, all of the libraries and programs will be found in either the Release or Debug subdirectory of the corresponding source directory. If you wish to install the software somewhere, edit the file $ROOT\install.bat to set the variable root to be the absolute pathname of the directory where you want the software installed, and then run the script $ROOT\install.bat from the $ROOT directory.

If you want to change source files, you can just do it and rebuild. If, however, you want to add new files or projects, you will have to redo the makefiles or scripts.

If you have problems or questions, please contact us at erg@research.att.com.