Difference between revisions of "Apertium on Windows"

From Apertium
Jump to navigation Jump to search
 
(160 intermediate revisions by 10 users not shown)
Line 1: Line 1:
  +
[[Installation sur Windows en utilisant cygwin|En français]]
  +
{{Github-migration-check}}
  +
This page is kept for historical purposes, if you want to install Apertium on Windows easily, see: [[Apertium_VirtualBox]]
  +
<hr>
  +
  +
{{dragons}}<br/>
 
{{TOCD}}
 
{{TOCD}}
   
  +
==Introductory notes==
We are in the process of porting Apertium to Windows. Lttoolbox has already been compiled successfully, but has not been tested extensively. We are now working on porting Apertium.
 
  +
  +
Apertium is Unix software (this includes [[Mac OS/X]]). It's not formally supported on Windows - though we would all ''like'' it to run on Windows, it's not supported. It seems that Apertium is a difficult beast to get working, which is odd for us, because in a unix environment, it "just works".
  +
  +
Cygwin, as a 'Unix-like' environment for Windows, is an easy target for us, because it fully supports <code>wstring</code> (wide-char strings, widely used by Apertium) since version 1.7.
  +
  +
Lttoolbox builds with Visual C++ without additional changes - provided that you follow the instructions in README.Win32.
  +
  +
You will also need a Unix-type shell, such as bash, to run it. Batch files simply will not work, as Windows does not have true support for program pipes ('|').<ref>Rather than pipe directly between processes, the 'DOS box' uses temporary files to emulate it: <code>ls|more</code> becomes the equivalent of <code>ls&gt;tmp;more&lt;tmp</code></ref>. A solution can be using <code>bash</code> under Cygwin.
   
 
==Getting the code==
 
==Getting the code==
   
  +
The lttoolbox changes are in the main SVN branch. Current win32 changes for apertium are in the branch apertium/win32
The Windows branch is currently in the [[Using the Apertium GIT repository|unofficial GIT repository]] under the "windows" branch. To contribute, first follow the steps on [[Using the Apertium GIT repository]]. Now, we'll create a branch called "windows", which will track the "windows" branch in the remote repository:
 
  +
  +
See instructions for [[using SVN]], or the simplest way:
  +
* Download and install [http://tortoisesvn.net/downloads TortoiseSVN]
  +
* Get a login/password for SourceForge at http://sourceforge.net/
  +
* Create a directory C:\Apertium, and right click/TortoiseSVN/Import... in it
  +
* Specify the URL of the repository: http://apertium.svn.sourceforge.net/svnroot/apertium and click OK
  +
* Use the source code in the directory "trunk" (not "branches")
  +
  +
=Building under Cygwin=
  +
  +
Cygwin is a Unix-like environment and command-line interface for Microsoft Windows, which provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment. Therefore it is possible to launch Windows applications from the Cygwin environment, as well as to use Cygwin tools and applications within the Windows operating context.
  +
  +
LTToolbox and Apertium can be easily built under Cygwin 1.7: first make sure you have all the needed dependencies; you can checkout LTToolbox' and Apertium's sources directly from Apertium's SVN repository by using Cygwin's shell with the following commands:
  +
 
<pre>
 
<pre>
  +
svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/lttoolbox lttoolbox
git branch --track windows origin/windows
 
  +
svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium apertium
 
</pre>
 
</pre>
   
  +
Then, by using Cygwin's <code>bash</code> shell, go in LTToolbox' sources directory:
To switch to the "windows" branch, issue:
 
  +
 
<pre>
 
<pre>
  +
cd lttoolbox
git checkout windows
 
 
</pre>
 
</pre>
  +
  +
And execute the following sequence of commands:
  +
  +
<pre>
  +
./autogen.sh --prefix=/usr
  +
make
  +
make install
  +
</pre>
  +
  +
Then go in Apertium's source directory and do the same:
  +
  +
<pre>
  +
cd ../apertium
  +
./autogen.sh --prefix=/usr
  +
make
  +
make install
  +
</pre>
  +
  +
Now you're ready to download and build language pairs and use them under Cygwin's shell.
  +
  +
=Building under Visual C++=
   
 
==Dependencies==
 
==Dependencies==
   
You will need to get Windows versions of the following tools and libraries to compile the code under Windows:
+
You will need to get Windows versions of the following tools and libraries to compile the code under Windows :
 
* [http://www.microsoft.com/express/vc/ Microsoft's C++ compiler] - the compiler is part of Visual Studio 2008 Express, which is available free of charge.
 
* [http://www.microsoft.com/express/vc/ Microsoft's C++ compiler] - the compiler is part of Visual Studio 2008 Express, which is available free of charge.
* [http://www.cmake.org CMake] - a cross platform build tool
+
* [http://www.cmake.org/cmake/resources/software.html CMake] - a cross platform build tool, download cmake-2.6.4-win32-x86.exe, at installation make sure you have CMakeSetup.exe in the bin directory.
 
* [http://xmlsoft.org libxml] - the Windows binaries are at [http://xmlsoft.org/sources/win32/ http://xmlsoft.org/sources/win32/]; you will need:
 
* [http://xmlsoft.org libxml] - the Windows binaries are at [http://xmlsoft.org/sources/win32/ http://xmlsoft.org/sources/win32/]; you will need:
  +
** libxml2 (install it in C:\Program Files\LibXML) from libxml2-2.7.6.win32.zip
** libxml2
 
  +
** zlib (install it in C:\Program Files\zlib) from zlib-1.2.3.win32.zip
** zlib
 
  +
** iconv (install it in C:\Program Files\iconv) from iconv-1.9.2.win32.zip
** libiconv
 
  +
** libxslt (install it in C:\Program Files\libxslt) from libxslt-1.1.26.win32.zip
** libxslt
 
  +
* [ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ pcre] - Download pcre-7.9.zip and unzip it (in C:\pcre for instance), next read <b>Building and installing pcre </b> below.
* [http://www.pcre.org/ libpcre] - there are no Windows binaries available and you will have to build this from the source code.
 
  +
** KDE/Win32 have packages for MinGW/MSVC [http://sourceforge.net/project/showfiles.php?group_id=214730&package_id=261982 here] -- I haven't checked them yet
* [http://gnuwin32.sourceforge.net/packages/flex.htm flex for Windows] - it's probably easiest if you just download the Windows installer version.
 
  +
* [http://gnuwin32.sourceforge.net/packages/flex.htm flex for Windows] - download and use the Windows installer version (http://sourceforge.net/projects/gnuwin32/files/flex/).
  +
  +
Insert the libxml2, zlib and iconv bin directories in the path variable, for information they are needed by xsltproc.exe.
   
 
==Setting up the required tools and libraries==
 
==Setting up the required tools and libraries==
Line 34: Line 88:
   
 
=== Installing CMake ===
 
=== Installing CMake ===
Next, download and install the Windows version of CMake. Let the installer place CMake in your path, since it will be much easier to run CMake from the command line if you do this.
+
Next, install the Windows version of CMake. Let the installer place CMake in your path, since it will be much easier to run CMake from the command line if you do this.
   
 
=== Installing the libxml libraries ===
 
=== Installing the libxml libraries ===
The zip files of libxml2, zlib, libiconv and libxslt all have the familiar UNIX layout:
+
The zip files of libxml2, zlib, iconv and libxslt all have the familiar UNIX layout:
 
<pre>
 
<pre>
 
|- bin
 
|- bin
Line 44: Line 98:
 
|- share
 
|- share
 
</pre>
 
</pre>
Unzip each of these archives and copy the bin, include, lib and share directories in each package into a common directory (the Windows branch in the GIT repository assumes <code>C:\Program Files\LibXML</code> as a default).
+
Unzip each of these archives and copy the bin, include, lib and share directories in each package into a common directory (<code>C:\Program Files\LibXML</code> by default).
   
=== Building and installing libpcre ===
+
=== Building and installing pcre ===
  +
You have unziped the pcre archive to a directory C:\pcre-7.9 (likely), create a diretory C:\pcre\build (for instance).
Now, unzip the libpcre archive to a temporary folder. To compile libpcre, you will need have Visual Studio AND CMake already installed on your system. Now, open the Visual Studio 8.0 Command Prompt ('''Start -> Visual C++ 9.0 Express Edition -> Visual Studio Tools -> Visual Studio 8.0 Command Prompt'''). In this command prompt, go to the directory where you unpacked libpcre. Execute:
 
  +
  +
Edit the file CMakeLists.txt and update the following by replacing OFF by ON:
  +
<pre>
  +
SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL
  +
"Enable support for the Unicode UTF-8 encoding.")
  +
</pre>
  +
  +
To compile it, you will need to have Visual Studio AND CMake already installed on your system. Open the Visual Studio 8.0 Command Prompt ('''Start -> Microsoft Visual C++ 2008 Express Edition -> Visual Studio Tools -> Visual Studio 2008 Command Prompt'''). In this command prompt, go to the pcre source directory and run:
 
<pre>
 
<pre>
 
cmakesetup .
 
cmakesetup .
 
</pre>
 
</pre>
Click the button labelled "Configure". CMake will prompt you with a dialog box where you must choose the kind of make files it will output; select NMake. Normally, after the first time you click "Configure", CMake will show you a number of build variables, all highlighted in red. Click "Configure" once more; if those variables are highlighted in gray, you can click "Ok".
+
Set the source code location (C:\pcre-7.9) and the build location (C:\pcre-7.9\build). Click on "Configure" and select "NMake Makefiles", CMake will show you a number of build variables, all highlighted in red, click "Configure" <b>once more</b>, if everything goes well the "OK" button will become active, hit it: as a result your "build" directory will be populated with a number of files for compiling the software.
   
To compile libpcre, run:
+
To compile pcre, go to your build directory (C:\pcre-7.9\build) and run:
 
<pre>
 
<pre>
 
nmake
 
nmake
</pre>
 
After the compilation has succeeded, run:
 
<pre>
 
nmake install
 
 
</pre>
 
</pre>
   
  +
When this is done, copy the file pcred.lib in your final pcre directory (C:\Program Files\pcre\lib for instance).
By default, libpcre installs to <code>C:\Program Files\PCRE</code>. You can change this in the <code>cmakesetup</code> by modifying the build variable <code>CMAKE_INSATLL_PREFIX</code>.
 
   
 
=== Installing flex ===
 
=== Installing flex ===
If you have downloaded the binary archive, unzip them into something like C:\Program Files\Flex. If you downloaded the Windows installer, then just follow the installation wizard :).
+
If you have downloaded the binary archive, unzip them into something like C:\Program Files\Flex. If you downloaded the Windows installer, then just follow the installation wizard.
   
 
== Building lttoolbox ==
 
== Building lttoolbox ==
   
Before you can build lttoolbox, you need to tell CMake where to find the libxml files (under Linux, CMake will use pkg-config to find where the packages are installed). Open <code>lttoolbox-unicode\CMakeLists.txt</code> and modify the lines
+
Before you can build lttoolbox, you need to tell CMake where to find the libxml files (under Linux, CMake will use pkg-config to find where the packages are installed). Open <code>lttoolbox\CMakeLists.txt</code> and modify the lines
 
<pre>
 
<pre>
SET(LIBXML2_INCLUDE_DIR C:/Program\ Files/LibXML/include)
+
SET (LIBXML2_BASE "C:/Program\ Files/LibXML")
  +
SET (LIBXML2_INCLUDE_DIR "${LIBXML2_BASE}/include")
SET(LIBXML2_LIBRARIES C:/Program\ Files/LibXML/libxml2.lib)
 
  +
SET (LIBXML2_LIBRARIES "${LIBXML2_BASE}/lib/libxml2.lib")
 
</pre>
 
</pre>
to match your installtion.
+
to match your installation.
   
Now, in the Visual Studio command prompt (the "DOS box") change the directory to lttoolbox-unicode and execute
+
Now, in the Visual Studio command prompt (again, Start -> Microsoft Visual C++ 2008 Express Edition -> Visual Studio Tools -> Visual Studio 2008 Command Prompt) change the directory to <code>lttoolbox</code> and execute
 
<pre>
 
<pre>
 
cmakesetup .
 
cmakesetup .
 
</pre>
 
</pre>
   
Click on the configure button. As with libpcre, CMake will ask you to choose the type of build file to generate. Again, choose "Nmake". If you get an error message about LIBXML, then it means that <code>LIBXML2_INCLUDE_DIR</code> or <code>LIBXML2_LIBRARIES</code> in <code>lttoolbox-unicode\CMakeLists.txt</code> has an incorrect value.
+
Click on the configure button. As with libpcre, CMake will ask you to choose the type of build file to generate. Again, choose "Nmake". If you get an error message about LIBXML, then it means that <code>LIBXML2_INCLUDE_DIR</code> or <code>LIBXML2_LIBRARIES</code> in <code>lttoolbox\CMakeLists.txt</code> has an incorrect value.
   
If everything completes without errors after the first time that you clicked the "Configure" button, you will again see a few lines in the appear in the cmakesetup window. They should be highlighted with red. You have the opportunity to change the installation directory of lttoolbox by modifying the build variable <code>CMAKE_INSATLL_PREFIX</code>. To continue, click "Configure" again; if everything is correct, then everything that was highlighted with red should now be highlighted with gray.
+
If everything completes without errors after the first time that you clicked the "Configure" button, you will again see a few lines in the appear in the cmakesetup window. They should be highlighted with red. You have the opportunity to change the installation directory of lttoolbox by modifying the build variable <code>CMAKE_INSTALL_PREFIX</code>. To continue, click <b>a second time</b> on "Configure"; if everything is correct, then everything that was highlighted with red should now be highlighted with gray and the OK button becomes active.
   
 
Next, click OK; CMake should generate NMake files. To compile, simply execute:
 
Next, click OK; CMake should generate NMake files. To compile, simply execute:
Line 94: Line 153:
 
nmake install
 
nmake install
 
</pre>
 
</pre>
  +
  +
== Building apertium ==
  +
  +
In order to build apertium, CMake needs to use the following tools and libraries:
  +
* libxml
  +
* libpcre
  +
* lttoolbox
  +
* xsltproc (you should have this since it is distributed with libxslt)
  +
* flex
  +
  +
At this point you should have all of the above and you simply need to set the correct CMake variables in order to build apertium. Open <code>apertium/CMakeLists.txt</code> (from the trunk directory) and find the section which should resemble the following:
  +
<pre>
  +
IF (WIN32)
  +
SET (WIN32_DIR ${PROJECT_SOURCE_DIR}/apertium/win32)
  +
INCLUDE_DIRECTORIES (${WIN32_DIR}; C:/apertium/trunk/lttoolbox; C:/pcre)
  +
LIST (APPEND EXTRA_SOURCES ${WIN32_DIR}/getopt.c ${WIN32_DIR}/libgen.c)
  +
  +
SET(FLEX_EXECUTABLE "${PROGRAM_FILES_PATH}/GnuWin32/bin/flex.exe")
  +
  +
SET(LIBXML2_BASE_DIR "${LIBXML2_BASE_DIR}/LibXML")
  +
SET(LIBXML2_INCLUDE_DIR "${LIBXML2_BASE_DIR}/include")
  +
SET(LIBXML2_LIBRARIES "${LIBXML2_BASE_DIR}/lib/libxml2.lib")
  +
  +
SET(LIBXSLT_BASE_DIR "${PROGRAM_FILES_PATH}/libxslt")
  +
SET(LIBXSLT_INCLUDE_DIR "${LIBXSLT_BASE_DIR}/include")
  +
SET(LIBXSLT_LIBRARIES "${LIBXSLT_BASE_DIR}/lib/libxslt.lib")
  +
SET(XSLTPROC_EXECUTABLE "${LIBXSLT_BASE_DIR}/bin/xsltproc.exe")
  +
  +
SET(LTTOOLBOX3_BASE_DIR "${PROGRAM_FILES_PATH}/apertium-3.1")
  +
SET(LTTOOLBOX3_INCLUDE_DIR "${LTTOOLBOX3_BASE_DIR}/include/lttoolbox-3.1")
  +
SET(LTTOOLBOX3_LIBRARIES "${LTTOOLBOX3_BASE_DIR}/lib/lttoolbox3.lib")
  +
  +
SET(LIBPCRE_BASE_DIR "${PROGRAM_FILES_PATH}/pcre")
  +
SET(LIBPCRE_INCLUDE_DIR "${LIBPCRE_BASE_DIR}/include")
  +
SET(LIBPCRE_LIBRARIES "${LIBPCRE_BASE_DIR}/lib/pcred.lib")
  +
  +
ADD_DEFINITIONS (/D _CRT_SECURE_NO_WARNINGS /D STDC_HEADERS /D PCRE_STATIC)
  +
ENDIF (WIN32)
  +
</pre>
  +
  +
The only variables you may need to adapt are:
  +
* <code>INCLUDE_DIRECTORIES</code>
  +
* <code>FLEX_EXECUTABLE</code>
  +
* <code>LIBXML2_BASE_DIR</code>
  +
* <code>LIBXSLT_BASE_DIR</code>
  +
* <code>LTTOOLBOX3_BASE_DIR</code>
  +
* <code>LIBPCRE_BASE_DIR</code>
  +
  +
These variables point to the base directories where the respective required tools and libraries are installed.
  +
  +
To build apertium, open the Visual Studio command prompt (as described earlier in this document) and change the directory to <code>apertium</code>. Now as before, run :
  +
<pre>
  +
cmakesetup .
  +
</pre>
  +
  +
Follow all of the build steps as described in the previous section which details how lttoolbox is built.
  +
  +
After the build completes, you should be able to install apertium by typing :
  +
<pre>
  +
nmake install
  +
</pre>
  +
  +
== Testing apertium ==
  +
  +
Go to the directory occitan-catalan directory (likely to be C:\Apertium\trunk\apertium-oc-ca) and do the following tests:
  +
  +
<pre>
  +
lt-comp lr apertium-oc-ca.ca.dix ca-oc.automorf.bin
  +
</pre>
  +
  +
expected results:
  +
<pre>
  +
apostrophes@postblank 1001 1543
  +
final@inconditional 28 537
  +
main@standard 36360 66910
  +
</pre>
  +
  +
try now:
  +
<pre>
  +
echo "Això és una prova" | lt-proc ca-oc.automorf.bin
  +
</pre>
  +
  +
expected results:
  +
<pre>
  +
^Això/Això<prn><tn><p3><nt>$ ^és/ser<vbser><pri><p3><sg>$ ^una/un<num><f><sp>/un<det><ind><f><sg>$ ^prova/prova<n><f><sg>/provar<vblex><imp><p2><sg>/provar<vblex><pri><p3><sg>$
  +
</pre>
  +
  +
next do:
  +
<pre>
  +
echo "Això és una prova" | lt-proc ca-oc.automorf.bin | apertium-tagger -g ca-oc.prob
  +
</pre>
  +
  +
expected results:
  +
<pre>
  +
^Això<prn><tn><p3><nt>$ ^ser<vbser><pri><p3><sg>$ ^un<det><ind><f><sg>$ ^prova<n><f><sg>$
  +
</pre>
  +
  +
==Notes==
  +
<references/>
   
 
[[Category:Installation]]
 
[[Category:Installation]]
  +
[[Category:Documentation in English]]

Latest revision as of 22:06, 7 March 2018

En français

WARNING

This page is out of date as a result of the migration to GitHub. Please update this page with new documentation and remove this warning. If you are unsure how to proceed, please contact the GitHub migration team.

This page is kept for historical purposes, if you want to install Apertium on Windows easily, see: Apertium_VirtualBox


Dragon.jpg

hic·sunt·dracones
Here be dragons! To make improvements, please dive right in. It is highly recommended that you hang out on the IRC channel (irc.oftc.net #apertium) and join the mailing list.


Introductory notes[edit]

Apertium is Unix software (this includes Mac OS/X). It's not formally supported on Windows - though we would all like it to run on Windows, it's not supported. It seems that Apertium is a difficult beast to get working, which is odd for us, because in a unix environment, it "just works".

Cygwin, as a 'Unix-like' environment for Windows, is an easy target for us, because it fully supports wstring (wide-char strings, widely used by Apertium) since version 1.7.

Lttoolbox builds with Visual C++ without additional changes - provided that you follow the instructions in README.Win32.

You will also need a Unix-type shell, such as bash, to run it. Batch files simply will not work, as Windows does not have true support for program pipes ('|').[1]. A solution can be using bash under Cygwin.

Getting the code[edit]

The lttoolbox changes are in the main SVN branch. Current win32 changes for apertium are in the branch apertium/win32

See instructions for using SVN, or the simplest way:

Building under Cygwin[edit]

Cygwin is a Unix-like environment and command-line interface for Microsoft Windows, which provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment. Therefore it is possible to launch Windows applications from the Cygwin environment, as well as to use Cygwin tools and applications within the Windows operating context.

LTToolbox and Apertium can be easily built under Cygwin 1.7: first make sure you have all the needed dependencies; you can checkout LTToolbox' and Apertium's sources directly from Apertium's SVN repository by using Cygwin's shell with the following commands:

svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/lttoolbox lttoolbox
svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium apertium

Then, by using Cygwin's bash shell, go in LTToolbox' sources directory:

cd lttoolbox

And execute the following sequence of commands:

./autogen.sh --prefix=/usr
make
make install

Then go in Apertium's source directory and do the same:

cd ../apertium
./autogen.sh --prefix=/usr
make
make install

Now you're ready to download and build language pairs and use them under Cygwin's shell.

Building under Visual C++[edit]

Dependencies[edit]

You will need to get Windows versions of the following tools and libraries to compile the code under Windows :

  • Microsoft's C++ compiler - the compiler is part of Visual Studio 2008 Express, which is available free of charge.
  • CMake - a cross platform build tool, download cmake-2.6.4-win32-x86.exe, at installation make sure you have CMakeSetup.exe in the bin directory.
  • libxml - the Windows binaries are at http://xmlsoft.org/sources/win32/; you will need:
    • libxml2 (install it in C:\Program Files\LibXML) from libxml2-2.7.6.win32.zip
    • zlib (install it in C:\Program Files\zlib) from zlib-1.2.3.win32.zip
    • iconv (install it in C:\Program Files\iconv) from iconv-1.9.2.win32.zip
    • libxslt (install it in C:\Program Files\libxslt) from libxslt-1.1.26.win32.zip
  • pcre - Download pcre-7.9.zip and unzip it (in C:\pcre for instance), next read Building and installing pcre below.
    • KDE/Win32 have packages for MinGW/MSVC here -- I haven't checked them yet
  • flex for Windows - download and use the Windows installer version (http://sourceforge.net/projects/gnuwin32/files/flex/).

Insert the libxml2, zlib and iconv bin directories in the path variable, for information they are needed by xsltproc.exe.

Setting up the required tools and libraries[edit]

Installing Visual Studio[edit]

Be sure to start downloading Visual Studio 2008 first, since it is a fairly big download.

Installing CMake[edit]

Next, install the Windows version of CMake. Let the installer place CMake in your path, since it will be much easier to run CMake from the command line if you do this.

Installing the libxml libraries[edit]

The zip files of libxml2, zlib, iconv and libxslt all have the familiar UNIX layout:

|- bin
|- include
|- lib
|- share

Unzip each of these archives and copy the bin, include, lib and share directories in each package into a common directory (C:\Program Files\LibXML by default).

Building and installing pcre[edit]

You have unziped the pcre archive to a directory C:\pcre-7.9 (likely), create a diretory C:\pcre\build (for instance).

Edit the file CMakeLists.txt and update the following by replacing OFF by ON:

SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL
    "Enable support for the Unicode UTF-8 encoding.")

To compile it, you will need to have Visual Studio AND CMake already installed on your system. Open the Visual Studio 8.0 Command Prompt (Start -> Microsoft Visual C++ 2008 Express Edition -> Visual Studio Tools -> Visual Studio 2008 Command Prompt). In this command prompt, go to the pcre source directory and run:

cmakesetup .

Set the source code location (C:\pcre-7.9) and the build location (C:\pcre-7.9\build). Click on "Configure" and select "NMake Makefiles", CMake will show you a number of build variables, all highlighted in red, click "Configure" once more, if everything goes well the "OK" button will become active, hit it: as a result your "build" directory will be populated with a number of files for compiling the software.

To compile pcre, go to your build directory (C:\pcre-7.9\build) and run:

nmake

When this is done, copy the file pcred.lib in your final pcre directory (C:\Program Files\pcre\lib for instance).

Installing flex[edit]

If you have downloaded the binary archive, unzip them into something like C:\Program Files\Flex. If you downloaded the Windows installer, then just follow the installation wizard.

Building lttoolbox[edit]

Before you can build lttoolbox, you need to tell CMake where to find the libxml files (under Linux, CMake will use pkg-config to find where the packages are installed). Open lttoolbox\CMakeLists.txt and modify the lines

SET (LIBXML2_BASE        "C:/Program\ Files/LibXML")
SET (LIBXML2_INCLUDE_DIR "${LIBXML2_BASE}/include")
SET (LIBXML2_LIBRARIES   "${LIBXML2_BASE}/lib/libxml2.lib")

to match your installation.

Now, in the Visual Studio command prompt (again, Start -> Microsoft Visual C++ 2008 Express Edition -> Visual Studio Tools -> Visual Studio 2008 Command Prompt) change the directory to lttoolbox and execute

cmakesetup .

Click on the configure button. As with libpcre, CMake will ask you to choose the type of build file to generate. Again, choose "Nmake". If you get an error message about LIBXML, then it means that LIBXML2_INCLUDE_DIR or LIBXML2_LIBRARIES in lttoolbox\CMakeLists.txt has an incorrect value.

If everything completes without errors after the first time that you clicked the "Configure" button, you will again see a few lines in the appear in the cmakesetup window. They should be highlighted with red. You have the opportunity to change the installation directory of lttoolbox by modifying the build variable CMAKE_INSTALL_PREFIX. To continue, click a second time on "Configure"; if everything is correct, then everything that was highlighted with red should now be highlighted with gray and the OK button becomes active.

Next, click OK; CMake should generate NMake files. To compile, simply execute:

nmake

To install lttoolbox, run:

nmake install

Building apertium[edit]

In order to build apertium, CMake needs to use the following tools and libraries:

  • libxml
  • libpcre
  • lttoolbox
  • xsltproc (you should have this since it is distributed with libxslt)
  • flex

At this point you should have all of the above and you simply need to set the correct CMake variables in order to build apertium. Open apertium/CMakeLists.txt (from the trunk directory) and find the section which should resemble the following:

IF (WIN32)
        SET (WIN32_DIR ${PROJECT_SOURCE_DIR}/apertium/win32)
        INCLUDE_DIRECTORIES (${WIN32_DIR}; C:/apertium/trunk/lttoolbox; C:/pcre)
        LIST (APPEND EXTRA_SOURCES ${WIN32_DIR}/getopt.c ${WIN32_DIR}/libgen.c)

        SET(FLEX_EXECUTABLE        "${PROGRAM_FILES_PATH}/GnuWin32/bin/flex.exe")

        SET(LIBXML2_BASE_DIR       "${LIBXML2_BASE_DIR}/LibXML")
        SET(LIBXML2_INCLUDE_DIR    "${LIBXML2_BASE_DIR}/include")
        SET(LIBXML2_LIBRARIES      "${LIBXML2_BASE_DIR}/lib/libxml2.lib")
        
        SET(LIBXSLT_BASE_DIR       "${PROGRAM_FILES_PATH}/libxslt")
        SET(LIBXSLT_INCLUDE_DIR    "${LIBXSLT_BASE_DIR}/include")
        SET(LIBXSLT_LIBRARIES      "${LIBXSLT_BASE_DIR}/lib/libxslt.lib")
        SET(XSLTPROC_EXECUTABLE    "${LIBXSLT_BASE_DIR}/bin/xsltproc.exe")

        SET(LTTOOLBOX3_BASE_DIR    "${PROGRAM_FILES_PATH}/apertium-3.1")
        SET(LTTOOLBOX3_INCLUDE_DIR "${LTTOOLBOX3_BASE_DIR}/include/lttoolbox-3.1")
        SET(LTTOOLBOX3_LIBRARIES   "${LTTOOLBOX3_BASE_DIR}/lib/lttoolbox3.lib")

        SET(LIBPCRE_BASE_DIR       "${PROGRAM_FILES_PATH}/pcre")
        SET(LIBPCRE_INCLUDE_DIR    "${LIBPCRE_BASE_DIR}/include")
        SET(LIBPCRE_LIBRARIES      "${LIBPCRE_BASE_DIR}/lib/pcred.lib")

        ADD_DEFINITIONS (/D _CRT_SECURE_NO_WARNINGS /D STDC_HEADERS /D PCRE_STATIC)
ENDIF (WIN32)

The only variables you may need to adapt are:

  • INCLUDE_DIRECTORIES
  • FLEX_EXECUTABLE
  • LIBXML2_BASE_DIR
  • LIBXSLT_BASE_DIR
  • LTTOOLBOX3_BASE_DIR
  • LIBPCRE_BASE_DIR

These variables point to the base directories where the respective required tools and libraries are installed.

To build apertium, open the Visual Studio command prompt (as described earlier in this document) and change the directory to apertium. Now as before, run :

cmakesetup .

Follow all of the build steps as described in the previous section which details how lttoolbox is built.

After the build completes, you should be able to install apertium by typing :

nmake install

Testing apertium[edit]

Go to the directory occitan-catalan directory (likely to be C:\Apertium\trunk\apertium-oc-ca) and do the following tests:

lt-comp lr apertium-oc-ca.ca.dix ca-oc.automorf.bin

expected results:

apostrophes@postblank 1001 1543
final@inconditional 28 537
main@standard 36360 66910

try now:

echo "Això és una prova" | lt-proc ca-oc.automorf.bin 

expected results:

^Això/Això<prn><tn><p3><nt>$ ^és/ser<vbser><pri><p3><sg>$ ^una/un<num><f><sp>/un<det><ind><f><sg>$ ^prova/prova<n><f><sg>/provar<vblex><imp><p2><sg>/provar<vblex><pri><p3><sg>$

next do:

echo "Això és una prova" | lt-proc ca-oc.automorf.bin  | apertium-tagger -g ca-oc.prob 

expected results:

^Això<prn><tn><p3><nt>$ ^ser<vbser><pri><p3><sg>$ ^un<det><ind><f><sg>$ ^prova<n><f><sg>$

Notes[edit]

  1. Rather than pipe directly between processes, the 'DOS box' uses temporary files to emulate it: ls|more becomes the equivalent of ls>tmp;more<tmp