## Graphviz Build Instructions for Windows

(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:

1. Install the third-party libraries. This is most easily done by installing a Windows binary verion of GTK 2.0 or later.
2. Download the Graphviz source package:
   Go to http://www.graphviz.org/Download_source.php and copy over either the stable release `graphviz-`VERSION`.tar.gz` or the development source package `graphviz-working.tar.gz`.
3. 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.
4. 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.
5. 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 -DWIN32 -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" (dot.demo/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:
     Go to http://www.graphviz.org/Download_windows.php and copy over either the release or development source package. At present, these can also be found as http://www.graphviz.org/pub/graphviz/ARCHIVE/graphviz-win.tgz and http://www.graphviz.org/pub/graphviz/CURRENT/graphviz-win.tgz, respectively.
  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:
     - zlib 1.1.3 http://www.gzip.org/zlib/
     - libpng 1.0.6 http://www.libpng.org/pub/png
     - jpeg-6b 62 http://www.ijg.org/
     - freetype 2.1.7 http://freetype.sourceforge.net/
     - expat http://expat.sourceforge.net/
     The versions should be at least the ones indicated. You can download the files from http://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.