-
Notifications
You must be signed in to change notification settings - Fork 24
build windows
How to build core components on Windows.
Note that you can get Libvoikko also as a prebuilt binary from here: http://www.puimula.org/htp/testing/voikko-sdk/win-crossbuild/
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.
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
andmake 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.
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
- If you are building from Git
./autogen.sh
-
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
- This will build for 32 bit Windows. To build for 64 bit Windows use
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
orx86_64-w64-mingw32-strip --strip-unneeded *.exe *.dll
- These can be stripped to save a lot of space:
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
-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
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 voikko-fi there. Binaries built there are exactly same as those build on Windows and build dependencies are far easier to install on Linux.