Difference between revisions of "Install Apertium core by compiling"

From Apertium
Jump to navigation Jump to search
(→‎Configure, build and install: dealing with pkg-config)
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
The below instructions are built from GNU/Linux material, but should be much the same on Apple, BSD, and other Unix-like systems.
 
The below instructions are built from GNU/Linux material, but should be much the same on Apple, BSD, and other Unix-like systems.
   
If you are on an Apple system, you may want to look at the detailed [[Install Apertium core by compiling#Apple systems |links below]].
+
If you are on an Apple system, you may want to look at [[Prerequisites for Mac OS X]] then [[Apertium on Mac OS X]] before returning here.
 
 
 
===Install the prerequisites===
 
===Install the prerequisites===
Line 28: Line 28:
   
   
=== Use Subversion to download the code ===
+
=== Use git to download the code ===
 
The main code,
 
The main code,
   
 
<pre>
 
<pre>
svn checkout https://svn.code.sf.net/p/apertium/svn/trunk/lttoolbox
+
git clone https://github.com/apertium/lttoolbox.git
svn checkout https://svn.code.sf.net/p/apertium/svn/trunk/apertium
+
git clone https://github.com/apertium/apertium.git
svn checkout https://svn.code.sf.net/p/apertium/svn/trunk/apertium-lex-tools
+
git clone https://github.com/apertium/apertium-lex-tools.git
 
</pre>
 
</pre>
   
   
* ''Note 1: Please make sure that the directory where you put these files (i.e. where you run the <code>svn</code> command) doesn't contain spaces and other special characters. That may cause errors while compiling/linking.''
+
* ''Note: Please make sure that the directory where you put these files (i.e. where you run the <code>git</code> command) doesn't contain spaces and other special characters. That may cause errors while compiling/linking.''
* ''Note 2: Sourceforge (https://sourceforge.net/projects/apertium/) naturally provides a full tarball download. Do not use this. The links above have a different address to the main Sourceforge address. They poke nto the SVN repository. The tarball compiles using './configure' instead of './autogen.sh'. Only packagers would be interested in using this.''
 
 
   
 
===Set up environment===
 
===Set up environment===
Line 83: Line 81:
 
sudo ldconfig
 
sudo ldconfig
 
</pre>
 
</pre>
  +
  +
When doing this, you might encounter a "cannot find pkg-config" error or something similar. You can solve this by installing pkg-config: <code>sudo apt-get install pkg-config</code>
   
 
If you specified a <code>$PREFIX</code> (e.g. to avoid installing as root), then you need to reset the prefix on 'autogen', so do this in each directory,
 
If you specified a <code>$PREFIX</code> (e.g. to avoid installing as root), then you need to reset the prefix on 'autogen', so do this in each directory,
Line 99: Line 99:
 
If you had any trouble, see [[Installation troubleshooting]].
 
If you had any trouble, see [[Installation troubleshooting]].
   
 
 
 
==Windows==
 
==Windows==
 
If you do not want to use the [[Apertium VirtualBox]], you can compile Apertium for Windows using Cygwin; documentation for how to compile on Windows manually is at [[Apertium on Windows]].
 
If you do not want to use the [[Apertium VirtualBox]], you can compile Apertium for Windows using Cygwin; documentation for how to compile on Windows manually is at [[Apertium on Windows]].
Line 106: Line 104:
 
There is also a script at [[Apertium guide for Windows users]], but it is currently out-of-date and in need of updating.
 
There is also a script at [[Apertium guide for Windows users]], but it is currently out-of-date and in need of updating.
   
 
==Apple systems==
 
If you do not want to use the [[Apertium VirtualBox]], you can compile Apertium on an Apples OS, [[Prerequisites for Mac OS X]] then [[Apertium on Mac OS X]].
 
   
   
Line 122: Line 117:
 
lt-proc
 
lt-proc
 
</pre>
 
</pre>
  +
  +
If you know you need the HFST or CG3 modules, see [[Installation of grammar libraries]]. You may also be interested in the many tips at [[Bash completion]].
   
 
You may want to write a new language pair, but you could download a language pair to test the install. Follow the instructions for [[Install language data by compiling]]. Or, if your system has packaging, download a language package (but beware, a package manager may pull in a old package of Apertium core, too).
 
You may want to write a new language pair, but you could download a language pair to test the install. Follow the instructions for [[Install language data by compiling]]. Or, if your system has packaging, download a language package (but beware, a package manager may pull in a old package of Apertium core, too).

Latest revision as of 15:26, 18 November 2018

Either you are planning to work on Apertium core, or have an operating system not covered by packaging, or virtual environments (check the Install overview).


Unix (GNU/Linux, Apple, BSD)[edit]

The below instructions are built from GNU/Linux material, but should be much the same on Apple, BSD, and other Unix-like systems.

If you are on an Apple system, you may want to look at Prerequisites for Mac OS X then Apertium on Mac OS X before returning here.

Install the prerequisites[edit]

Install prerequisites,

Notes for different systems[edit]

These notes have been made at different times. Some may be out-of-date. However, if you are having difficulties, they may contain some tips,


Use git to download the code[edit]

The main code,

git clone https://github.com/apertium/lttoolbox.git
git clone https://github.com/apertium/apertium.git
git clone https://github.com/apertium/apertium-lex-tools.git


  • Note: Please make sure that the directory where you put these files (i.e. where you run the git command) doesn't contain spaces and other special characters. That may cause errors while compiling/linking.

Set up environment[edit]

By default, Apertium is installed under the directory /usr/local, which requires root (sudo) access when installing. If that's fine with you, begin by pasting these lines into your terminal:

LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
export PKG_CONFIG_PATH

You should also put those lines in your ~/.bashrc so you don't have to paste them into every terminal you open.

However, if you want Apertium installed somewhere else or don't want to install it as root, instead paste these lines into your terminal:

PREFIX=$HOME/local # or wherever you want apertium stuff installed
LD_LIBRARY_PATH=$PREFIX/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:${PKG_CONFIG_PATH}
export PKG_CONFIG_PATH

You should also put those lines in your ~/.bashrc so you don't have to paste them into every terminal you open.


Configure, build and install[edit]

The next step is to configure, build and install each of the modules you checked out, in this order:

  1. lttoolbox
  2. apertium
  3. apertium-lex-tools

cd to each of the directories before you run the the commands shown below.

If you didn't specify $PREFIX above, or don't know what this means, then do this in each directory,

./autogen.sh
make
sudo make install
sudo ldconfig

When doing this, you might encounter a "cannot find pkg-config" error or something similar. You can solve this by installing pkg-config: sudo apt-get install pkg-config

If you specified a $PREFIX (e.g. to avoid installing as root), then you need to reset the prefix on 'autogen', so do this in each directory,

./autogen.sh --prefix=$PREFIX
make
make install
ldconfig -n $PREFIX/lib


(If you're on a Mac, you don't need to do ldconfig, don't worry that it fails.)


If you had any trouble, see Installation troubleshooting.

Windows[edit]

If you do not want to use the Apertium VirtualBox, you can compile Apertium for Windows using Cygwin; documentation for how to compile on Windows manually is at Apertium on Windows.

There is also a script at Apertium guide for Windows users, but it is currently out-of-date and in need of updating.


Troubleshooting[edit]

Compiles go wrong. Of course they do,


Continuing[edit]

One way to test you have something, immediately, it to try invoke a tool. Without language data you can't see a translation, but you can see the help. Try,

lt-proc

If you know you need the HFST or CG3 modules, see Installation of grammar libraries. You may also be interested in the many tips at Bash completion.

You may want to write a new language pair, but you could download a language pair to test the install. Follow the instructions for Install language data by compiling. Or, if your system has packaging, download a language package (but beware, a package manager may pull in a old package of Apertium core, too).