How to compile Dia

Steffen Macke


This document describes (step by step) how to compile Dia on Windows, Mac OS X and Ubuntu.

Dia is a diagram editor. More information about dia is available from

Dia Development VM

The Dia Development VM allows to compile the latest Dia version using a single mouse click. The VM uses Ubuntu and is available from

Compiling Dia for Windows

This section describes how to compile Dia for Windows using Microsoft Visual C++ Version 6.0 and the GTK+ Development Environment.

Folder structure

Understanding the folder structure is helpful especially when unzipping developer packages:


Sometimes the zip files contain the bin, include and lib inside another folder. While unzipping, make sure that their contents end up in c:\gtk\bin, c:\gtk\include and c:\gtk\lib.

Installing the required software

Install Microsoft Visual C++ Version 6.0

Start the Visual C++ Installation Wizard (Figure 1, “Visual C++ 6.0 installation wizard”) and click Next.

Figure 1. Visual C++ 6.0 installation wizard

Visual C++ 6.0 installation wizard

If you agree to the license (Figure 2, “Visual C++ license dialog”), put the checkmark and click Next.

Figure 2. Visual C++ license dialog

Visual C++ license dialog

Enter the registration information in the form (Figure 3, “Visual C++ product ID dialog”) and click Next.

Figure 3. Visual C++ product ID dialog

Visual C++ product ID dialog

When asked for the installation location (Figure 4, “Visual C++ installation location”), choose c:\Program Files\Microsoft Visual Studio\Common and click Next.

Figure 4. Visual C++ installation location

Visual C++ installation location

To continue with the installation processs (Figure 5, “Visual C++ standard setup”), click Next

Figure 5. Visual C++ standard setup

Visual C++ standard setup

Note down the Product ID (Figure 6, “”) and click OK.

Figure 6. 

When asked for the setup type (Figure 7, “Visual C++ setup type”), click on the Standard button.

Figure 7. Visual C++ setup type

Visual C++ setup type

When asked to register the environment variables (Figure 8, “Visual C++ environment variables”), you can leave the option to register the environment variables unchecked, though it does no harm to check this option. Click OK

Figure 8. Visual C++ environment variables

Visual C++ environment variables

Read the information about the NT debug symbols (Figure 9, “NT debug symbols”) and click OK.

Figure 9. NT debug symbols

NT debug symbols

Note that the Visual C++ setup has finished successfully (Figure 10, “Visual C++ setup success”) and click OK.

Figure 10. Visual C++ setup success

Visual C++ setup success

Install MSDN Library

Start the MSDN setup (Figure 11, “MSDN Library setup dialog”) and verify that the option to install MSDN is checked. Click Next.

Figure 11. MSDN Library setup dialog

MSDN Library setup dialog

Enter the path of your CD-DROM drive (Figure 12, “CD-ROM drive selection”) and click OK.

Figure 12. CD-ROM drive selection

CD-ROM drive selection

If you agree to the license terms (Figure 13, “MSDN Library setup”), click Next.

Figure 13. MSDN Library setup

MSDN Library setup

Note down the Product ID shown in Figure 14, “MSDN Library Product ID” for future reference and click OK.

Figure 14. MSDN Library Product ID

MSDN Library Product ID

If you agree to the license terms (Figure 15, “License terms”), click I agree.

Figure 15. License terms

License terms

When asked for the installation type (Figure 16, “MSDN Library installation type”), click on Standard.

Figure 16. MSDN Library installation type

MSDN Library installation type

When the MSDN Library setup is complete (Figure 17, “MSDN Library setup complete”), click OK.

Figure 17. MSDN Library setup complete

MSDN Library setup complete

You may register your Visual C++ copy online (Figure 18, “Visual C++ registration”). Click Finish to leave the installation wizard.

Figure 18. Visual C++ registration

Visual C++ registration

Install Visual Studio 6 Service Pack 6

Download Visual Studio 6 Service Pack 6 can be downloaded from

Start the Visual Studio 6 Service Pack 6 setup.

When asked for a location to place the extracted files (Figure 19, “Temporary files location”), specify a temporary folder, e.g. c:\tmp. Click OK>.

Figure 19. Temporary files location

Temporary files location

When asked if the temporary folder should be created (Figure 20, “Temporary folder creation”), click Yes.

Figure 20. Temporary folder creation

Temporary folder creation

Start the Visual Studio 6.0 Service Pack 6 setup (Figure 21, “Visual Studio 6.0 Service Pack 6 welcome page”) from the temporary folder and click Continue.

Figure 21. Visual Studio 6.0 Service Pack 6 welcome page

Visual Studio 6.0 Service Pack 6 welcome page

If you agree to the Visual Studio 6.0 Service Pack 6 license agreement (Figure 22, “Visual Studio 6.0 Service Pack 6 License Agreement”), click I Agree.

Figure 22. Visual Studio 6.0 Service Pack 6 License Agreement

Visual Studio 6.0 Service Pack 6 License Agreement

When asked for a Windows reboot (Figure 23, “Windows reboot”), click Windows reboot.

Figure 23. Windows reboot

Windows reboot

Install the GTK+ All-in-one-bundle

The GTK+ All-in-one bundle should be used and can be downloaded from Sourceforge.

Unzip the contents of the folder to C:\GTK.

Copy c:\gtk\bin\intl.dll to c:\gtk\bin\libintl.dll.

Install iconv

While glib includes its own copy of iconv, libxml2 requires a separate iconv installation.

The libxml2 iconv version can be downloaded from

Unzip the file and copy the contents of the iconv-1.9.2.win32 folder to C:\GTK.

Install libxml2

Download libxml2 from

Unzip the file and copy the contents of the libxml2-2.7.8.win32 folder to C:\GTK.

Installing optional software

The following software packages are optional, because they can be used to create the full Dia for Windows installer, but they are not necessary to just build the Dia binaries or compile a plug-in.

Install LibArt_LGPL

LibArt_LGPL is the graphics library used by Dia's libart plugin. It is available from

Extract the contents of and to c:\gtk.

In case you don't want to compile the libart plugin, comment it out in plug-ins/makefile.msc.

Use the following script to create libart_lgpl_2-2.lib:

dumpbin /exports c:\gtk\bin\libart_lgpl_2-2.dll > c:\gtk\lib\libart_lgpl_2-2.dumpbin
echo EXPORTS > c:\gtk\lib\libart_lgpl_2-2.def
sed -n "/RVA/,/Summary/p" c:\gtk\lib\libart_lgpl_2-2.dumpbin | sed -n "/[0-9]/p" | sed "s/.* //" >> c:\gtk\lib\libart_lgpl_2-2.def
lib /def:c:\gtk\lib\libart_lgpl_2-2.def /out:c:\gtk\lib\libart_lgpl_2-2.lib /machine:x86


NSIS is used to build the Dia installer.

Install Python 2.3

If you intend to build the Python plug-in, install Python 2.3 to c:\python23.

Newer Python versions are not build against msvcrt.dll and thus require to rebuild all libraries that Dia is linked against. Therefore building Dia with newer Python versions is not covered by this document.

In case you don't want to compile the Python plugin and language bindings, comment out the nmake calls for the bindings and plug-ins\python folders. Edit c:\gtk\dia\makefile.msc as indicated by the comments in the file (around lines 58 and 67).

Install swig

The swig command is required to build the Python bindings.

Download swig from and unzip swig.exe and the lib folder to C:\GTK\bin.

Install LibXSLT

The LibXSLT library is used by the xslt plugin. Thus you won't be able to build the xslt plugin without LibXSLT.

Download libxslt from

Unzip the file and copy the contents of the libxslt-1.1.26.win32 folder to C:\GTK.

In case you don't want to compile the xslt plugin, comment it out in plug-ins/makefile.msc.

Install librsvg

The librsvg library is used to render SVG images as image objects. Note that librsvg is not used for the SVG import, SVG export or the Dia shapes.

Download, and from

Unzip those files and copy the contents to C:\GTK.

Getting the Dia sources

Any serious Dia development should use the latest sources from the GNOME Git repository: git://

In case you don't know how to use Git or you don't want to use it, you can also use a source tarball from the Dia download pages.


For the instructions of this tutorial to work, the Dia sources should be located in c:\gtk\dia.

Additional sources for the MSVC build

Download and unzip the contents to c:\.

Patch to work around Bug #679417

Download and apply the following patch: 0001-Bug-679417-Work-around-libpixbufloaders-.dll-install.patch


Using the Visual C++ 6.0 build environment (the section called “Install Microsoft Visual C++ Version 6.0”): Starting from c:\gtk\dia, the following commands are necessary to compile dia:

cd \GTK\dia
nmake /f makefile.msc

Putting everything together

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

Copy an existing Dia for Windows installation to C:\GTK\dia\build\win32. Delete the contents of C:\GTK\dia\build\win32\bin and C:\GTK\dia\build\win32\dia. Run the following commands:

cd \GTK\dia
nmake /f makefile.msc full

Congratulations, you should now be able to run your copy of dia by executing C:\GTK\bin\dia.



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

Console Output

In order to enable console output, use dia.exe, not diaw.exe. This allows to see error and warning messages produced by dia.

Additional 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 mailing lists may contain useful information.

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


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.


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. This applies to all GTK+ libraries which you'll have to rebuild on your own.

This also applies to newer Visual C++ versions.

Compiling Dia for Windows with gcc from the MinGW distribution should be possible. However, compilation with gcc is not covered in this document. Make sure to check Dia's bugzilla for MinGW-related patches.


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.

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.

Updated cairo version

The cairo DLL (version 1.10.2) included in the GTK+ all-in-one bundle 2.24.10 has some bugs. See e.g. bug #679651. An updated cairo DLL (e.g. version 1.12.16) can be build using the openSUSE Build Service. You can branch the package to start your own development. When doing so, remember to add the windows:mingw:win32 repository via the advanced interface. This is necessary in order to locate libraries on which cairo depends.


Starting from a vanilla Ubuntu 12.04 deskop installation, you can install the necessary packages using the following command:

sudo apt-get install autoconf automake autotools-dev git git-core gsfonts-x11 \
intltool libatk1.0-dev libcairo-gobject2 libcairo2-dev liberror-perl \
libexpat1-dev libfontconfig1-dev libfreetype6-dev libgdiplus \
libgdk-pixbuf2.0-dev libgif4 libglib2.0-bin libglib2.0-dev \
libgtk2.0-dev libice-dev libltdl-dev libmono-accessibility2.0-cil \
libmono-data-tds2.0-cil libmono-messaging2.0-cil libmono-sqlite2.0-cil \
libmono-system-data2.0-cil libmono-system-messaging2.0-cil \
libmono-system-web2.0-cil libmono-wcf3.0-cil \
libmono-winforms2.0-cil libmono2.0-cil libpango1.0-dev libpixman-1-dev \
libpng12-dev libpthread-stubs0 libpthread-stubs0-dev libsm-dev libsqlite0 \
libssl-dev libtool libx11-dev libxau-dev libxcb-render0-dev libxcb-shm0-dev \
libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev \
libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxml2-dev \
libxrandr-dev libxrender-dev m4 python-sip python2.7-dev swig \
x11proto-composite-dev x11proto-core-dev x11proto-damage-dev x11proto-fixes-dev \
x11proto-input-dev x11proto-kb-dev x11proto-randr-dev x11proto-render-dev \
x11proto-xext-dev x11proto-xinerama-dev xtrans-dev zlib1g-dev libart-2.0-dev

Clone the git repository, for example:

git clone git://

Enter the dia directory and start the build process using the following commands:

cd dia
./configure --prefix=/usr --with-python --with-swig --with-libart

To install, run the following command:

make install

Mac OS X

MacPorts can be used to compile Dia for Mac OS X. A readymade Portfile is available. The MacPorts documentation is great and contains everything you need to build Dia on your Mac.

When compiling 32-bit on a 64-bit-capable CPU, remember to set build_arch to i386 in macports.conf before the installation of any ports.

Sign the App bundle:

codesign -s "Developer ID Application"
Businesswoman draws a diagram