Difference between revisions of "Compiling Inkscape on Windows 32-bit"

From Inkscape Wiki
Jump to navigation Jump to search
Line 68: Line 68:
Now you can start the build proccess by simply running btool.
Now you can start the build process by simply running btool.
     ...\> btool
     ...\> btool
Grab a coffee and find something else to do. The build process can normally continue in the background while you're doing other stuff on your PC.
If everything went well, you should now have you fresh Inkscape in the ...\Inkscape\Inkscape directory.
If everything went well, you should now have you fresh Inkscape in the ...\Inkscape\Inkscape directory.
==== Dealing With Build Errors ====
==== Dealing With Build Errors ====

Revision as of 05:42, 13 March 2008

See the Win32 Build ticket for some info.

Inkscape under Windows

Inkscape was originally written for Linux, but has been ported to other platforms, including Windows, through the work of a number of dedicated developers.

You can get pre-built binaries of the Windows releases (both stable and development) from the Inkscape download page

Building Your Own Binary

As well as getting a pre-built binary, you can also build your own. You may do this for fun, to learn about programming, or to help test or improve Inkscape.

Several steps are required to build your own binary, as follows;

  • You need to download the source code
  • You will need to download and install the MinGW compiler
  • You will also need the supporting libraries used by Inkscape
  • If you wish to apply patches for bug-testing, you will also need to download the patch utility

Getting The Inkscape Source

Ishmal provides a snapshot of the latest SVN source on his website - http://inkscape.modevia.com/svn-snap/

Download the latest file (or earlier if testing bugs) and decompress it. It does not need to be in a particular place, so put it wherever is convenient for you.

Getting The Compiler & Libraries

Ishmal also provides a complete set of compiler and libraries on his website. You can get all packages from http://inkscape.modevia.com/win32libs/.

Before you download, check for the last versions. As of February 28th 2008 those are:

The configuration files expect the packages in specific directories:

  • the compiler C:\MinGW (referenced by mingwenv.bat)
  • other libraries C:\devlibs (referenced in build.xml used by buildtool)

Patching The Source Code

To patch the Inkscape source code, you will need the patch program. One of the best places to get it is from the GnuWin32 project - http://gnuwin32.sourceforge.net/packages/patch.htm

This page has binaries, source and documentation for patch. You can put the patch program wherever you like, as it works indepently from the compiler.

One way of patching a particular module of code is to copy that code into the patch directory, as well as the patch/diff file, and then after patching to copy the patched file back to the source directory. Note: there can sometimes be several code modules with the same name (eg: print.cpp is in three places, but all are different)

To do the actual patching, you will again need to be in a command window. To patch, type something like the following;

    ...>patch --binary {modulename}.cpp {modulename}.cpp.patch

You should now have a patched code module to copy back to the same spot in the source tree.


  • The --binary switch is only necessary if the files contain the wrong sort of line endings. The GnuWin32 Patch page notes the following; "On MS-Windows, the patchfile must be a text file, i.e. CR-LF must be used as line endings. A file with LF may give the error: "Assertion failed, hunk, file patch.c, line 343," unless the option '--binary' is given."
  • Requirements for patch are "Win32, i.e. MS-Windows 95 / 98 / ME / NT / 2000 / XP / 2003 / Vista with msvcrt.dll and msvcp60.dll. If msvcrt.dll or msvcp60.dll is not in your Windows/System folder, get them from Microsoft, or (msvcrt.dll only) by installing Internet Explorer 4.0 or higher."

Building The Binary

You will need to open a command window (DOS prompt) to build the binary. Go to the Start Menu, select Run, and then type command (or cmd). Now you need to step into the Inkscape source directory:

   ...\> cd ...\inkscape

Ishmal's SVN snapshots include some convenient tools to help Windows users build a binary. Firstly run the batch file that sets up the MinGW environment variables

   ...\> mingwenv.bat

Now, build the magic make replacement:

   ...\> g++ buildtool.cpp -o btool

or, if you get errors about gettimeofday:

   ...\> g++ -DNEED_GETTIMEOFDAY buildtool.cpp -o btool

Now you can start the build process by simply running btool.

   ...\> btool

Grab a coffee and find something else to do. The build process can normally continue in the background while you're doing other stuff on your PC.

If everything went well, you should now have you fresh Inkscape in the ...\Inkscape\Inkscape directory.

Dealing With Build Errors

More information soon

For more information

We will update this page soon with information on how to build Inkscape on the Win32 platform. In the meantime, there are some fairly complete notes on how to build the current package with either Mingw on Windows, or a cross-compiler on Linux, at


(note: http://inkscape.modevia.com/win32libs/ may have more complete and up-to-date library packages).

Create the Setup package for Win32

To create the setup package you need the NSIS installer on your PC. Get that from http://nsis.sf.net . You have successfully built Inkscape and everything is in the ...\Inkscape\Inkscape\ directory. Open the ...\Inkscape\packaging\win32\inkscape.nsi using the NSIS program and compile the package. Sooo easy :-)

A Note from Jon about UNICODE on Win32

Actually, Microsoft themselves never use _UNICODE, nor it's 'evil' friends TCHAR and _T. If it is used, it results in a binary that can not be run on Windows 95/98/ME. It is more of a "Windows NT only" define.

Microsoft applications like MS Office have been pure 16-bit Unicode internally for years now. Also remember that BSTRs in Win32 are required to have 16-bit Unicode data. So for any COM access on a Win32 box running Win9x/ME 'multibyte' or '8-bit' COM calls convert all ANSI data to Unicode once you pass things in. To avoid this, Microsoft just keeps data 16-bit Unicode and then translates to local ANSI codepage only when data needs to be passed directly to a Win32 call.

To help developers, Microsoft finally made public their API they had been using. It's "The Microsoft Layer for Unicode".

Although that simplifies things, it's not required. I've done Win32 programs that are 16-bit Unicode and run on Windows 95/98/ME with no problems years before they released that.

Soo.... _UNICODE can't be used as it makes your binary unusable on Win9x/ME. Then it turns out that TCHAR and _T can't be used either. (Oh, and MS can't really use them, since Office does run on Win9x/ME). So just explicitly use some 16-bit datatype for chars. Microsoft is misleading in their documentation when they state that wchar_t is 16-bit. Most other platforms (including Mac OS, Linux, Solaris, BSD, etc) follow the language standard's recommendation and make it 32-bit. So it is best to avoid wchar_t for any real cross-platform code.

So, some general guidelines are:

  • Never define _UNICODE
  • Don't use _T
  • Don't use TCHAR
  • Don't use wchar_t
  • Use some explicit 16-bit type for characters/strings

So then it's a simple matter of converting data from the standard UTF-8 GTK+ data to UTF-16 data before passing to Win32-land.

The result? A single binary that executes properly on both Win9X/ME and WinNT/2K/XP, including full and proper font and filename support.

And, as I've mentioned before, I've actually achieved this for a few different shipping products and projects.

-- Jon C

SVN and Windows

If you want to access Inkscapes' subversion repository on SourceForge from Windows, I'd heartily recommend TortoiseSVN. It has the SSH stuff built into it so you don't have to mess about with putty, and it integrates right into Explorer, so SVN becomes just an extension of the right-click file commands. get it from http://tortoisesvn.net/