1
:version: $RCSfile: index.rst,v $ $Revision: 76e0bf38aaba $ $Date: 2011/03/22 00:48:41 $
5
=========================
6
Building |Tesseractocr|
7
=========================
9
The Visual Studio 2008 Solution for |Tesseractocr| builds:
15
+ 9 training applications (for v3.02)
17
Unlike earlier Solutions only a single `libtesseract` library is
18
generated --- the twelve projects matching the twelve source subfolders
19
have been abandoned. They were deemed too complicated since they were
20
never (rarely?) used by themselves, but only along with the entire
23
In addition, `libtesseract` and `tesseract.exe` can be built using four
24
configurations: :guilabel:`LIB_Release`, :guilabel:`LIB_Debug`,
25
:guilabel:`DLL_Release`, and :guilabel:`DLL_Debug`.
27
Two Visual Studio Property Sheets, `leptonica_versionnumbers.vsprops`
28
and `tesseract_versionnumbers.vsprops`, are employed to isolate the
29
Solution from changes in dependency version numbers (and isolate
30
dependent Solutions). See :ref:`APITest's <APITest>` :ref:`LIB_Release
31
<apitest-lib-release>` Linker :guilabel:`Additional Dependencies`
32
settings for an example of what this looks like in practice. See
33
|Leptonica|\ ’s explanation `About version numbers in library filenames
34
<http://tpgit.github.com/UnOfficialLeptDocs/vs2008/downloading-binaries.html#about-version-numbers>`_
35
for the rationale behind using Property Sheets.
38
Building `libtesseract` and `tesseract.exe`
39
===========================================
41
1. Open `C:\\BuildFolder\\tesseract-3.0x\\vs2008\\tesseract.sln` in Visual
44
You'll see the following projects in the :guilabel:`Solution
45
Explorer` (for v3.02)::
59
2. Select the build configuration you'd like to use from the
60
:guilabel:`Solution Configurations` dropdown. It lists the following
68
The `DLL_` configurations build the DLL version of `libtesseract-3.0x`
69
(and link with the DLL version of Leptonica 1.68). The `LIB_`
70
configurations build the static library version of `libtesseract-3.0x`
71
(and link with the static version of Leptonica 1.68 and the required
74
3. Build `libtesseract` by right-clicking the
75
:guilabel:`libtesseract30x` project and choosing
76
:menuselection:`B&uild` from the pop-up menu.
78
The resultant library will be written to the
79
`C:\\BuildFolder\\tesseract-3.0x\\vs2008\\<ConfigurationName>` directory
80
where `<ConfigurationName>` is the same as the build configuration you
81
selected earlier. It is also copied to the `C:\\BuildFolder\\lib` folder
82
to make it easy to link your own applications to `libtesseract`.
84
The library is named as follows (for v3.02):
90
`libtesseract302-static.lib`
91
`libtesseract302-static-debug.lib`
95
`libtesseract302.lib` (import library)
97
`libtesseract302d.lib` (import library)
98
`libtesseract302d.dll`
100
4. Build the main tesseract OCR application by right-clicking the
101
:guilabel:`tesseract` project and choosing :menuselection:`B&uild`.
103
The resultant executable will be written to the
104
`C:\\BuildFolder\\tesseract-3.0x\\vs2008\\<ConfigurationName>` directory
105
where `<ConfigurationName>` is the same as the build configuration you
106
selected earlier. It is named as follows:
110
LIB_Release: `tesseract.exe`
111
LIB_Debug: `tesseractd.exe`
112
DLL_Release: `tesseract-dll.exe`
113
DLL_Debug: `tesseract-dlld.exe`
116
Testing `tesseract.exe`
117
=======================
119
It's usually better to make a separate directory to test
120
`tesseract.exe`. To run tesseract, you either need to make sure your
121
test directory contains the `tessdata` tesseract language data folder or
122
you set the ``TESSDATA_PREFIX`` environment variable to point to it. See
123
http://code.google.com/p/tesseract-ocr/wiki/ReadMe for important
126
For example, you can use the following directory structure::
135
Copy your tesseract executable to `C:\\BuildFolder\\testing`. If you
136
built a DLL version then be sure to also copy the required DLLs to the
137
same directory (or add `C:\\BuildFolder\\lib` to your ``PATH`` --
138
However, this isn't really recommended).
140
For example, if you are trying to run `tesseractd.exe` then you'll need
141
to also copy the following to `C:\\BuildFolder\\testing`::
146
Copy a few test images to `C:\\BuildFolder\\testing` just to make it easy
147
to run test commands.
149
Test tesseract by doing something like the following::
151
tesseractd.exe eurotext.tif eurotext
153
This will create a file called `eurotext.txt` that will contain the
154
result of OCRing `eurotext.tif`.
157
Building the training applications
158
==================================
160
The training related applications are built using the following
175
Currently these applications can **ONLY** be built with the LIB_Debug
176
and LIB_Release configurations. If you try to use a DLL configuration
177
you'll get "undefined external symbol" errors.
179
To build one of the above training applications, simply right-click one
180
of the projects in the Solution Explorer, and choose
181
:menuselection:`B&uild` from the pop-up menu.
183
Alternatively, you can build :bi:`everything` in the Solution by
184
choosing :menuselection:`&Build --> &Build Solution` (:kbd:`Ctrl+Shift+B`)
187
See http://code.google.com/p/tesseract-ocr/wiki/TrainingTesseract3 for
188
more information on using these applications.
191
.. _building-with-vc2008-express:
193
Building |Tesseractocr| with Visual C++ 2008 Express Edition
194
============================================================
196
The Solution file that comes with |Tesseractocr| was created with Visual
197
Studio 2008, and is compatible for the most part with the free `Visual
198
C++ 2008 Express Edition
199
<http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express>`_. You
200
might, however, sometimes see the following error message::
202
Fatal error RC1015: cannot open include file 'afxres.h'
204
.. _version-resource:
206
The Solution uses resource files to set application and DLL properties
207
that are visible on Windows 7 when you right-click them in Windows
208
Explorer, choose :menuselection:`Properties`, and look at the
209
:guilabel:`Details` tab (the :guilabel:`Version` tab on Windows XP).
211
.. image:: images/dll_properties_details_tab.png
213
:alt: Windows 7 Properties' Details Tab
215
Unfortunately, the Express Edition doesn't include the Resource
216
Editor. So in all resource files::
220
has to be changed to::
224
If someone has used the VS2008 Resource Editor to change a `.rc` file
225
associated with an application or DLL and forgotten to make these
226
changes before checking the file in, you'll see the above "Fatal error"
227
message. Simply manually make the change to fix the error.
234
indent-tabs-mode: nil
235
sentence-end-double-space: t
239
tab-stop-list: (3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60)