build windows

Harri Pitkänen edited this page Dec 19, 2015 · 10 revisions

How to build core components on Windows.

Prebuilt binaries for Windows

Note that you can get Libvoikko also as a prebuilt binary from here:


GCC or Clang compiler is recommended for building Libvoikko. Using MSVC is also possible but may require some build system hacking from time to time.

Build with GCC

The autotools build system does support Windows. It has some advantages compared to building with MSVC: more configuration options are available, no manual steps are required to generate source files and since it is used on Linux it is more likely to be up to date during the development cycle. Libraries generated with GCC have had compatibility problems with MSVC applications like LibreOffice but these should now be gone with the new API introduced in libvoikko 3.0.

  • Install MinGW tools (C compiler, C++ compiler and developer tools)
  • Install Python
  • Start MinGW shell
  • Make sure python.exe is in your PATH
  • If you are working on a Git clone run autoreconf --force --install to generate configure script.
  • Run ./configure (with options), make and make install to build libvoikko, just as you would do on Linux or OS X.

If you redistribute the binaries you need to ship libstdc++6.dll and libgcc_s_dw2-1.dll (exact names depend on the version of GCC) along with the library.

Cross-compiling from Linux with GCC

If you have a recent Linux distribution installed this could be by far the easiest way to build libvoikko. At least on Debian you can just

  • apt-get install mingw-w64
  • CXXFLAGS=-Wno-long-long ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes ./configure --host=i686-w64-mingw32
    • This will build for 32 bit Windows. To build for 64 bit Windows use --host=x86_64-w64-mingw32
    • You may want to specify the default fallback directory for dictionary lookup such as C:\voikko. This can be done with --with-dictionary-path=C:\\\\voikko
  • make
  • make install
  • Ship the resulting binaries with the compiler and standard libraries (libstdc++-6.dll and libgcc_s_sjlj-1.dll)
    • These can be stripped to save a lot of space: i686-w64-mingw32-strip --strip-unneeded *.dll *.exe or x86_64-w64-mingw32-strip --strip-unneeded *.exe *.dll

Statically linked libvoikko-1.dll with GCC

As noted above these instructions will generate dll libraries that require specific compiler and C++ support libraries to run correctly. To produce a completely self contained dll that does not depend on anything outside operating system core libraries you can use a slightly modified build procedure with GCC. This has been tested with cross compiler but would presumably work with MinGW on Windows.

  • Set the following CXXFLAGS and LDFLAGS for configure (in addition to the options mentioned above):

    LDFLAGS='-static-libstdc++ -static-libgcc' CXXFLAGS='-static-libstdc++ -static-libgcc -Wno-long-long'

  • Build as usual. Once the build has finished, find the command that was used to link libvoikko-1.dll from command history. The command should start with

    i686-w64-mingw32-g++ -shared -nostdlib

  • Copy that particular command into a text editor. Modify the beginning of the command so that


    is replaced with

    -shared -static -static-libgcc -static-libstdc++

  • Enter subdirectory src and paste the modified command back to terminal. Now the linking will be re-done to produce a self contained dll which can be found from .libs/libvoikko-1.dll

Build with MSVC

Libvoikko comes with MSVC project files that can be used to build the library and test tools with Microsoft Visual C++ compiler. MSVC 2013 Express edition has been tested to work but there are hopefully no problems with using later versions. Please note that the MSVC build system is a secondary build system and may not be up to date with the latest changes in the source code, not even in released builds.

One file (src/autocorrect/data.hpp) needs to be generated with a Python script before actually starting the build process. The MSVC build system does not do that automatically. Install Python and run

python src/autocorrect/ data/autocorrect/fi_FI.xml src/autocorrect/data.hpp

to take care of that. Now you can build libvoikko as you would build any MSVC project. It is also possible to build the test tools (voikkospell etc.) but those do not work very well on Windows at the moment. In practice it is easier to use the Python module if you want to do quick testing on Windows.

If you redistribute the binaries you should make sure that the MSVC runtime libraries are present on the target system. It is important that exactly right version of the libraries is available. The Express editions do not allow you to ship the redistributable with the program. Your may need to ask the user to download the library directly from Microsoft. You should switch to release configuration before building binaries for end users (on the toolbar: Solution Configurations dropdown) since debug binaries will not work without debug runtime.


Install Python 3, Foma, GNU Make, sed, sort and cat. Once those are in the PATH you should be able to build voikko-fi by running make vvfst.

Finding, building and installing the required tools can take some time. If you have access to a Linux system consider building Suomi-malaga there. Binaries built there are exactly same as those build on Windows and build dependencies are far easier to install on Linux.