Daniel@0: Daniel@0: Daniel@0: Graphviz Build Instructions for Windows Daniel@0: Daniel@0: Daniel@0:

Graphviz Build Instructions for Windows

Daniel@0:

Daniel@0: (Graphviz versions ≥ 2.22) Daniel@0:

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

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

Building with Visual Studio

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

Building with MinGW

Daniel@0:
    Daniel@0:
  1. Install MinGW and Msys. This gives a mini GNU-like compile environment Daniel@0:
  2. Set environment variables based on your machine, giving values to the Daniel@0: first six below: Daniel@0: Daniel@0:
    Daniel@0: export INSTALLROOT           # Root install directory
    Daniel@0: export GTKDIR                # Root of GTK tree
    Daniel@0: export FONTCONFIGINCLUDEDIR  # Path of fontconfig include dir
    Daniel@0: export FONTCONFIGLIBDIR      # Path of fontconfig lib dir
    Daniel@0: export FREETYPEINCLUDEDIR    # Path of freetype2 include dir
    Daniel@0: export FREETYPELIBDIR        # Path of freetype2 lib dir
    Daniel@0: 
    Daniel@0: export CFLAGS="-DGVDLL=1"
    Daniel@0: export CPPFLAGS="-I$GTKDIR/include -I$GTKDIR/include/freetype2 "
    Daniel@0: export LDFLAGS="-L$GTKDIR/lib -no-undefined"
    Daniel@0: export FONTCONFIG_CFLAGS=-I$GTKDIR/include/
    Daniel@0: export FONTCONFIG_LIBS="-L$FONTCONFIGLIBDIR -lfontconfig"
    Daniel@0: export FREETYPE2_CFLAGS=-I$FREETYPEINCLUDEDIR
    Daniel@0: export FREETYPE2_LIBS="-L$FREETYPELIBDIR
    Daniel@0: export PKG_CONFIG=$GTKDIR/bin/pkg-config
    Daniel@0: export PKG_CONFIG_PATH=$GTKDIR/lib/pkgconfig
    Daniel@0: 
    Daniel@0: export PANGOFLAGS="--with-fontconfig --with-fontconfiglibdir$FONTCONFIGLIBDIR --with-fontconfigincludedir=$FONTCONFIGINCLUDEDIR --with-pangocairo"
    Daniel@0: 
    Daniel@0: 
    Daniel@0:
    Daniel@0:
  3. Change directory to $ROOT and run configure:
    Daniel@0: Daniel@0:
    Daniel@0: ./configure -C --prefix=$INSTALLROOT --without-gdk-pixbuf --with-mylibgd --disable-swig --without-x  --disable-tcl --without-ipsepcola --with-codegens --enable-shared --disable-static --with-freetype=$GTKDIR/lib --enable-ltdl $PANGOFLAGS --without-gtk --without-gtkgl
    Daniel@0: 
    Daniel@0: 
    Daniel@0:
    Daniel@0: When configure finishes, it lists all of the Graphviz features that have been Daniel@0: enabled. If there are problems, you can check for errors in config.log. Daniel@0: You may have to add or modify Daniel@0: other flags and environment variables for configure to give you the Daniel@0: settings you want. Run configure --help Daniel@0: to see the allowed options and environment variables. Daniel@0:
  4. Run make Daniel@0:
  5. Run make install Daniel@0:
Daniel@0: These builds create a feature-full version of Graphviz. You can tailor Daniel@0: them to your wants. This is fairly simple for MinGW: just remove or reset Daniel@0: the flag of the option you don't want. For Visual Studio, you will probably Daniel@0: need to reset some of the values in config.h and some of the Daniel@0: compile-time options. Daniel@0:
Daniel@0:

Daniel@0: (2.21 >= Graphviz versions > 2.14) Daniel@0:

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

Daniel@0: To build Graphviz: Daniel@0:

    Daniel@0:
  1. Daniel@0: Install the third-party libraries. This is most easily done by installing Daniel@0: a Windows binary verion of GTK 2.0 or later. Daniel@0:
  2. Daniel@0: Download the Graphviz source package:
    Go to Daniel@0: http://www.graphviz.org/Download_source.php Daniel@0: and copy over either the stable release graphviz-VERSION.tar.gz Daniel@0: or the development source package graphviz-working.tar.gz. Daniel@0:
  3. Daniel@0: Unwrap the package:
    Daniel@0: You can use, for example,

    Daniel@0: gunzip < graphviz-working.tar.gz | tar xf -
    Daniel@0: Daniel@0:
    Daniel@0: Let $ROOT be the directory in which you stored the Graphviz source. Daniel@0:
  4. Daniel@0: Configure the package for your system:

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

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

    Daniel@0: make install

    Daniel@0:
Daniel@0:

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

Daniel@0:
  • Install MinGW and Msys. This gives a mini GNU-like compile environment Daniel@0: that produces Windows-compatible results. Daniel@0:
  • You may need to configure and build in Windows "Safe mode". Try Daniel@0: ./configure in normal mode; if it dies with "fork" problems, use Safe mode. Daniel@0:
  • Edit the "configure" file.
    Daniel@0: after this line:
    Daniel@0: DEFS=-DHAVE_CONFIG_H
    Daniel@0: add these lines:
    Daniel@0: Daniel@0:
    Daniel@0:     case "$host_os" in
    Daniel@0:      mingw*)
    Daniel@0:        DEFS="$DEFS -DWIN32 -DMSWIN32"
    Daniel@0:        ;;
    Daniel@0:      esac
    Daniel@0: 
    Daniel@0:
    Daniel@0:
  • run configure:
    Daniel@0: Daniel@0:
    Daniel@0:    ./configure  --enable-static=yes --enable-shared=no 
    Daniel@0: --prefix=/usr/local/ --with-libgd=no --enable-ltdl=no --disable-swig  
    Daniel@0: --disable-sharp --disable-guile --disable-io --disable-java 
    Daniel@0: --disable-lua --disable-ocaml --disable-perl --disable-php 
    Daniel@0: --disable-python --disable-ruby --disable-tcl
    Daniel@0: 
    Daniel@0:
    Daniel@0:
  • edit lib/Makefile
    Daniel@0: replace these lines:
    Daniel@0: Daniel@0:
    Daniel@0:  SUBDIRS = cdt graph agraph gd pathplan agutil sfio vmalloc ast vpsc \
    Daniel@0:      circogen dotgen fdpgen neatogen twopigen common pack gvc \
    Daniel@0:      ingraphs expr
    Daniel@0: 
    Daniel@0:
    Daniel@0: Daniel@0: with these lines:
    Daniel@0: Daniel@0:
    Daniel@0:  SUBDIRS = cdt graph agraph gd pathplan  vpsc \
    Daniel@0:     circogen dotgen fdpgen neatogen twopigen common pack gvc \
    Daniel@0:     ingraphs
    Daniel@0: 
    Daniel@0: make  # builds most of "lib" (see Makefile changes), cmd/dot and 
    Daniel@0: cmd/tools - stops on cmd/gvpr
    Daniel@0: make install
    Daniel@0: 
    Daniel@0:
    Daniel@0:
  • Daniel@0: here is the command line I used to build "simple.c" (dot.demo/simple.c), Daniel@0: after adding a few lines based on Daniel@0: https://mailman.research.att.com/pipermail/graphviz-interest/2006q2/003586.html Daniel@0: Daniel@0: Daniel@0: Daniel@0:
    Daniel@0: X=simple;gcc -v -I'/usr/local/include/graphviz' -I'/usr/local/include' 
    Daniel@0: -o $X -O $X.c  -L/usr/local/lib -L/usr/local/lib/graphviz -lgvc  -lgraph 
    Daniel@0: -lpathplan -lcdt -lgvplugin_core -lgvplugin_dot_layout 
    Daniel@0: -lgvplugin_neao_layout -lgvplugin_gd -lgvplugin_pango -lgvc -lpathplan
    Daniel@0: 
    Daniel@0:
    Daniel@0:

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


    Daniel@0:

    Daniel@0: (2.14 >= Graphviz versions >= 2.3) Daniel@0:

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

      Daniel@0:
    1. Daniel@0: Download the Windows source package from: Daniel@0: http://www.graphviz.org/Download_windows.php. Daniel@0:
    2. Daniel@0: Daniel@0:
    3. Daniel@0: Unwrap the package:
      Daniel@0: If you have Unix tools available, you can use Daniel@0: Daniel@0: gunzip < graphviz-win.tgz | tar xf -
      Daniel@0: Daniel@0: If not, double click on the file and WinZip should start up and let you Daniel@0: store all of the files into a directory.
      Daniel@0: Let $ROOT be the directory in which you stored the Graphviz source. Daniel@0:
    4. Daniel@0: Daniel@0:
    5. Daniel@0: Add the third-party libraries: Daniel@0: Daniel@0: Daniel@0: Daniel@0: The versions should be at least the ones indicated. Daniel@0: You can download the files from Daniel@0: http://www.graphviz.org/Misc/third-party.zip. Daniel@0: Unzip the package in the $ROOT directory; this will create a subdirectory called Daniel@0: third-party. Daniel@0: Or you can obtain the libraries yourself, and install Daniel@0: them in $ROOT\third-party Daniel@0: Also note that these libraries come with the binary release. Daniel@0:
    6. Daniel@0: Daniel@0:
    7. Daniel@0: Build the software in one of the following ways:
      Daniel@0:
        Daniel@0:
      • Run the script $ROOT\build.bat while in the $ROOT Daniel@0: directory. You'll first want to check Daniel@0: that the vc variable points to your local installation of visual C. Daniel@0: Obviously, this should be run in a DOS command window. Daniel@0:
      • The file $ROOT\ws\graphviz.dsw Daniel@0: is the main workspace for the Graphviz libraries and graph drawing programs. Daniel@0: The file Daniel@0: $ROOT\ws\tools.dsw provides the workspace for the Daniel@0: additional Graphviz tools. Double-clicking on these files will open the Daniel@0: workspaces using the MS Visual Studio, from which you can use the Build Daniel@0: menu item to create the various libraries and programs. Daniel@0: Daniel@0: Note that we have avoided all dependencies (i.e., there are no .dep files) Daniel@0: because we found they tended to include absolute pathnames. Daniel@0: If necessary, follow the order used in build.bat to be safe. Daniel@0:
      • If you have a Unix environment, with a real ksh, run the script Daniel@0: $ROOT\wmake.sh Daniel@0: after setting the PATH, LIB and INCLUDE shell variables to the paths where Daniel@0: the Visual C programs are installed on your machine, and the associated Daniel@0: library and include file directories. Daniel@0:
      Daniel@0:
    Daniel@0:

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

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

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