The build instructions for Linux also apply to other UNIX like operating systems.
- A compiler for C and C++: GCC or Clang
- GNU Autotools: autoconf, automake, libtool
- autoconf-archive
- pkg-config
- Leptonica
- libpng, libjpeg, libtiff
If they are not already installed, you need the following libraries (Ubuntu 16.04/14.04):
sudo apt-get install g++ # or clang++ (presumably)
sudo apt-get install autoconf automake libtool
sudo apt-get install autoconf-archive
sudo apt-get install pkg-config
sudo apt-get install libpng-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install libtiff5-dev
sudo apt-get install zlib1g-dev
if you plan to install the training tools, you also need the following libraries:
sudo apt-get install libicu-dev
sudo apt-get install libpango1.0-dev
sudo apt-get install libcairo2-dev
You also need to install Leptonica. Ensure that the development headers for Leptonica are installed before compiling Tesseract.
Tesseract versions and the minimum version of Leptonica required:
Tesseract | Leptonica | Ubuntu |
---|---|---|
4.00 | 1.74.2 | Must build from source |
3.05 | 1.74.0 | Must build from source |
3.04 | 1.71 | Ubuntu 16.04 |
3.03 | 1.70 | Ubuntu 14.04 |
3.02 | 1.69 | Ubuntu 12.04 |
3.01 | 1.67 |
One option is to install the distro's Leptonica package:
sudo apt-get install libleptonica-dev
but if you are using an oldish version of Linux, the Leptonica version may be too old, so you will need to build from source.
The sources are at https://github.com/DanBloomberg/leptonica . The instructions for building are given in Leptonica README.
Note that if building Leptonica from source, you may need to ensure that /usr/local/lib is in your library path. This is a standard Linux bug, and the information at Stackoverflow is very helpful.
Please follow instructions in https://github.com/tesseract-ocr/tesseract/wiki/Compiling--GitInstallation
Also read Install Instructions
Tesseract can be configured to install anywhere, which makes it possible to install it without root access.
To install it in $HOME/local:
./autogen.sh
./configure --prefix=$HOME/local/
make
make install
To install it in $HOME/local using Leptonica libraries also installed in $HOME/local:
./autogen.sh
LIBLEPT_HEADERSDIR=$HOME/local/include ./configure \
--prefix=$HOME/local/ --with-extra-libraries=$HOME/local/lib
make
make install
- Download the data file(s) for the language(s) you interest in.
- Move it to the
tessdata
directory (e.g. 'mv tessdata $TESSDATA_PREFIX' if definedTESSDATA_PREFIX
)
You can also use:
export TESSDATA_PREFIX=/some/path/to/tessdata
to point to your tessdata directory (example: if your tessdata path is '/usr/local/share/tessdata' you have to use 'export TESSDATA_PREFIX='/usr/local/share/').