Compiling Dia for Win32

Steffen Macke

$Date: 2004/07/10 17:07:42 $


Introduction

This document describes how to compile dia for Win32.

Dia is a diagram editor. More information about dia can be found on the dia homepage, http://www.lysator.liu.se/~alla/dia/. The dia homepage has links to the latest dia sources.

A binary distribution of dia for Win32 is available from http://dia-installer.sourceforge.net.

Tools

This section describes which tools are required in order to compile dia with the current set of makefiles.

Compiler

The MS Visual C++ compiler is used to compile dia for win32. Versions 5, 6 have been used successfully. The compiler is invoked using the cl command.

Caution

When compiling with Visual C++ version 7, you'll have to recompile all libraries as you'll have to link against msvcrt7.dll instead of msvcrt.dll.

Compiling dia for win32 with gcc from the MinGW distribution should be possible. However, compilation with gcc is not covered in this document.

Make

The makefiles work with MS nmake. The nmake tool comes with MS Visual Studio.

Command line interpreter

The standard MS command line interpreter cmd.exe is used to compile dia.

Libraries

Dia depends on a number of libraries, most noticeable the GTK+ toolkit. Instead of compiling all those libraries from scratch, it is recommended to use prebuild binaries of the relevant libraries.

Developer packages of the libraries are available from http://dia-installer.sourceforge.net/sources.html. However the original websites of the different projects are mentioned below in order to make updating easier.

GTK+

The GTK+ toolkit is available from http://www.gtk.org

Libart

The GnuWin32 project provides binaries for a number of open source libraries and tools. The homepage of the project is http://gnuwin32.sourceforge.net.

In order to build dia with the libart renderer, it is recommended to use the libart and freetype development packages provided by GnuWin32.

Libxml2

A libxml2 version with zlib compression support should be used. The Dia Win32 Installer home page provides such a version.

Libxslt

The Dia Win32 Installer homepage provides a binary and source packages suitable to be used with the dia XSLT plug-in.

Fontconfig

Tor Lillqvist has packaged fontconfig for Win32. This version is available from the Dia Win32 Installer home page.

Fontconfig depends on expat. Expat is available from http://expat.sourceforge.net

Dia Sources

Any serious dia development should use the latest dia sources from GNOME CVS. The dia homepage (See introduction) contains information on how to obtain the latest dia sources from CVS.

WinCVS is an excellent CVS client for Windows. The CvsGui homepage, http://cvsgui.sourceforge.net has all the details.

Environment

Directory structure

This section describes in which structure the various sources have to be arranged in order to compile dia. Please follow these steps:

  1. Choose a folder under which all sources will be kept. This folder will be referred to as $TOP in the following.

  2. Download the GLIB, ATK, PANGO, GTK, fontconfig files from the Dia Win32 Installer homepage. Extract to $TOP.

  3. Download expat from http://expat.sourceforge.net and install to $TOP.

  4. Download http://umn.dl.sourceforge.net/sourceforge/gnuwin32/libart-2.3.3-1-lib.zip and http://umn.dl.sourceforge.net/sourceforge/gnuwin32/libart-2.3.3-bin.zip. Extract to $TOP.

  5. Download http://umn.dl.sourceforge.net/sourceforge/gnuwin32/freetype-2.1.8.exe Install to $TOP.

  6. Download http://umn.dl.sourceforge.net/sourceforge/dia-installer/libxml2-2.6.11.zip. Install to $TOP.

  7. Download http://umn.dl.sourceforge.net/sourceforge/dia-installer/libxslt-1.1.8.zip.

    Extract to $TOP.
  8. Download libpng and zlib from http://gnuwin32.sourceforge.net. Install to $TOP.

  9. Download WIMP from gtk-wimp.sourceforge.net. Install to $TOP.

  10. copy dia\config.h.win32 dia\config.h
  11. copy bin\glib-genmarshal.exe include\glib-2.0\gobject
  12. Comment out unistd.h line in zconf.h

  13. Add LIBART_CFLAGS to make.msc

  14. Download http://uml.dl.sourceforge.net/sourceforge/dia-installer/dia_extra_src_msvc_dia_0.94-pre1.zip and unzip to $TOP.

    Caution

    This is replacing files. Make sure that you unzip this file last.

  15. Find out in which directory your copy of MS Visual Studio is installed. This directory will be referred to as $MSVC in the following.

Environment Variables

There are several ways to set Environment variables: Either through the System in the Control Panel or through commands in the command line with the set command. As the variables set through the Control Panel are persistent, you might prefer this way.

Replace $TOP and $MSVC with the real directory names.

The LIB environment variable is used by the linker. It should contain at least the following directories (MSVC Version 6):

  • $MSVC\VC98\lib

  • $TOP\lib\

The INCLUDE environment variable is used by the compiler. It should contain at least the following directories (MSVC Version 6):

  • $MSVC\VC98\include

  • $TOP\include

The PATH enviroment variable is used by the commandline interpreter to determine the location of executables. It should contain at least the following directories (MSVC Version 6, Windows 2000):

  • $MSVC\VC98\bin

  • $MSVC\common\msdev98\bin

  • $TOP\bin

  • c:\winnt\system32

Build Files

With the setup mentioned above, you should be able to compile dia out of the box. However, you should know which files control the build process. In addition to the various makefile.msc's that are introduced below, there are two important files:

  • $TOP\glib\build\win32\make.msc, included by makefile.msc

  • $TOP\glib\build\win32\module.defs, included by make.msc

If you're working with updated versions of some of the libraries you may have to edit these files.

Compilation

Starting from $TOP/dia, the following commands are necessary to compile dia:

cd lib
nmake makefile.msc
cd ../app
nmake makefile.msc
cd ../objects
nmake makefile.msc
cd ../plug-ins
nmake makefile.msc

Putting everything together

In order to run dia sucessfully, the binaries have to be put in the correct file structure.

A makefile is provided to copy the necessary files together. Starting from $TOP/dia, run the following command:

nmake makefile.msc

Congratulations, you should now be able to run your copy of dia by executing $TOP/dia/build/win32/bin/dia.

Troubleshooting

Debugging

In order to enable debugging, run nmake -f makefile.msc DEBUG=1.

Additional sources of information

Make sure to read the information provided by Hans Breuer and Tor Lillqvist, in particular the comments in the build files and the files named *.win32 in the glib, GTK+ and dia sources

The archives of the dia and gimpwin-dev may contain useful information.

If none of the above sources contain information to solve your problem, contact the author of this document: Steffen Macke

Console Output

In order to enable console output, change /subsystem:windows to /subsystem:console in $TOP/dia/app/makefile.msc. This allows to see error and warning messages produces by dia.