Integrating your application with Enchant – Part 2


Welcome to the second article exploring how to integrate the spell checking library Enchant into your Visual C++ applications.

I will be using this library with my freeware program NoteKeeper, which I am currently maintaining/developing in two versions of Visual C++.

  • Visual C++ 6 SP6 with STLPort 5.1.5, Multithreaded DLL
    (cl.exe v12.00.8804, link.exe v6.00.8447)
  • Visual C++ 9 SP1, Multithreaded DLL
    (cl.exe v15.00.30729.01, link.exe v9.00.30729.01)

Enchant isn’t actually a spell checking library in itself; it is more accurately described as a compatibility layer across the existing spell checking libraries (aspell, pspell, and myspell being amongst the most notable).

Part 2 – Building the Enchant Library

In the first part we built the support libraries that Enchant depends on. In this article we will continue by building the main Enchant library and the so-called ‘back-end provider’ libraries that do most of the work.

Libenchant and its providers

libenchant.dll provides a bridge that allows us to pick and choose which spell checking algorithms to use without changing the interface.

The spell checking algorithms are implemented in back-end providers that are loaded on demand by libenchant.dll. A provided will typically be packaged in a dll name in the format libenchant_<provider>.dll, where <provider> is the name of the spell-checking library/algorithm used. Thus libenchant_aspell.dll is the back-end provider for the aspell library.

So, the enchant library and its current providers are shown in green below. As you can see, some providers depend on other libraries, which are shown in orange.

Enchant Provider Dependencies

To keep things a bit less complicated I’ll only be building the ISpell and MySpell providers.

Download Enchant

I’m using the latest vesion of Enchant from the abisource repository, which at the time of writing was revision 25464.

To get access to the latest sources you’ll need a Subversion client installed. I use CollabNet’s Subversion Client.

Get the latest source using the following command.

  • svn co enchant

Download Visual C++ Makefile

Enchant supports Windows development with Visual C++ by providing solution (*.sln) and project (*.vcproj) files. Because I am targetting both Visual C++ 6 and 9, I’ve hacked together my own makefile so that I get consistency between the two targets. I’m hoping that the makefile will soon be included in the enchant library itself, but until then download it from here.

Place the makefile into your enchant\msvc folder.

Patches for Visual C++ 6

I couldn’t get the myspell provider to work without patching two of the source files. Download the patches from here.

Unzip the patches into your enchant\src\myspell folder and apply thus:

  • patch -i dictmgr.diff
  • patch -i myspell_checker.diff

Build Prerequisites

The makefile assumes that the GNU utility sed is available on your system. If you don’t have it, you can get it from


The build process should be as simple as running the makefile, replacing the paths with your own ones.

Run the following from your enchant/msvc folder. For MSVC6 add the option MANIFEST=0.

  • nmake -f Makefile.msvc DLL=1 MFLAGS=-MD PREFIX=<usr-path> GLIBDIR=<glib-path>

My full command for MSVC6 was nmake -f Makefile.msvc DLL=1 MFLAGS=-MD PREFIX=C:\usr-msvc6 GLIBDIR=D:\dev\lib\msvc6\glib.

How come I’ve only got MySpell and ISpell providers?

It seemed like a good idea to first prove that I could get enchant building in Visual C++ 6 using the providers that were the easiest to build, before I went onto the more complicated one.

The reason the MySpell and ISpell providers are easy to build is that they have all their spell-checking code built into the provider. The other ones all link with spell-checking libraries to provide their functionality.

I will be building the other providers in due course, but for now I am satisfied with these two.

Testing Enchant

I peformed some basic testing using the following steps. You should make sure that your libglib-2.0-0.dll, libgmodule-2.0-0.dll, iconv.dll and intl.dll binaries are available either in the directory you’re working or accessible in your PATH environment variable.

Also, you should install some ISpell or MySpell dictionaries by following the instructions from Palaso at

  1. Move the libenchant_ispell.dll and libenchant_myspell.dll into a lib\enchant subfolder of your enchant\bin\release folder.
  2. Run enchant-lsmod to verify that enchant can access your providers.
  3. Run enchant-lsmod -list-dicts to verify that enchant can access your dictionaries.
  4. Run test-enchant to verify that some basic functionality is present.

To Be Continued…

In the next part we will take the Wordpad MFC sample and add some [very basic] spell-checking functionality to it.


Thanks to Dom Lachowicz for creating Enchant and for the Win32 build instructions he has provided (see Build.win32.readme in the Enchant library).

by Alex Paterson ( Copyright © 2009. Permission is granted to distribute this article without fee as long as the copyright notice remains intact and any modifications are clearly indicated as such.

2 thoughts on “Integrating your application with Enchant – Part 2”

Leave a Reply