1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

build/windows

Building for 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 OpenOffice.org 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.

Openoffice.org-voikko

Building openoffice.org-voikko requires a recent version of OpenOffice.org (like 3.2.1), OpenOffice.org SDK of same version and a MSVC compiler supported by the SDK. Additionally you need to install

  • GNU Make, GNU Sed and zip to C:\voikko\bin
  • headers of libvoikko (src/*.h from libvoikko source package) to C:\voikko\include\libvoikko
  • libvoikko-1.dll and libvoikko-1.lib (these you get by building libvoikko with MSVC) to C:\voikko\lib

Unpack the source package. If you are building a standalone extension (which is what usually is done on Windows) you should create directory extras under the source tree and place libvoikko-1.dll there. Additionally you can place any dictionaries you want to ship with the extension under that directory. At least extras/2/mor-standard is recommended.

Open Windows command prompt and go to the source directory. Run setsdkenv_windows.bat from OOo SDK. On the first run it will ask a series of questions. You need to provide correct paths for the office, SDK, MSVC, GNU Make and zip installations. There are other questions too, answers to them do not matter here. When paths to office and SDK are asked you should use the legacy "8.3" names for directories that contain spaces in their names, for example C:\PROGRA~1\OPENOF~1.ORG. Finally the script creates another bat script that can be used later to initialize the build environment without going through the same questions again.

Some settings in the Makefile need to be changed for the build. You can either edit the file directly or pass the variables to make on the command line.

  • LIBVOIKKO_PATH=c:/voikko
  • STANDALONE_EXTENSION_PATH=extras
  • SHOW_LICENSE=1 (only if you want to distribute the extension as an independent product)

Finally start the build by running make oxt. During the build xcopy may ask about overwriting certain files in the build directory, you can allow it to do that. If everything goes fine the final extension can be found from build/voikko.oxt.