Skip to content
hatapitk edited this page Jul 4, 2012 · 12 revisions

How to build core components on Windows

Libvoikko

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 2005 Express edition has been tested to work but there are hopefully no problems with using later versions.

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/triecompiler.py 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.

Build with GCC

Using GCC instead of MSVC is also possible. 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.

Compiling with GCC on Windows was not tested in the last few releases on libvoikko. Thus it will only work out of the box in SVN trunk after release of libvoikko 3.1.

  • 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 SVN checkout 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
  • Run ./configure --host=i686-w64-mingw32 (with options), make and make install.
    • This will build for 32 bit Windows. To build for 64 bit Windows use --host=x86_64-w64-mingw32
  • 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:

    LDFLAGS='-static-libstdc++ -static-libgcc' CXXFLAGS='-static-libstdc++ -static-libgcc'}}} ./configure ...

  • 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

    -shared

    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

Suomi-malaga

Install Python, Malaga, GNU Make, sed and cat. Once those are in the PATH you should be able to build Suomi-malaga by running make.

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 on any little endian Linux system (any x86, either 32 or 64 bit, will do) are exactly same as those build on Windows and build dependencies are far easier to install on Linux.

Clone this wiki locally