~vcs-imports/tesseract-ocr/trunk

« back to all changes in this revision

Viewing changes to vs2008/sphinx/building.rst

  • Committer: zdenop at gmail
  • Date: 2012-02-26 15:30:05 UTC
  • Revision ID: svn-v4:d0cd1f9f-072b-0410-8dd7-cf729c803f20:trunk:681
vs2008 and vs2010 replaced with Tom Powers solution

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
:version: $RCSfile: index.rst,v $ $Revision: 76e0bf38aaba $ $Date: 2011/03/22 00:48:41 $
 
2
 
 
3
.. default-role:: fs
 
4
 
 
5
=========================
 
6
 Building |Tesseractocr|
 
7
=========================
 
8
 
 
9
The Visual Studio 2008 Solution for |Tesseractocr| builds:
 
10
 
 
11
+ `libtesseract`
 
12
 
 
13
+ `tesseract.exe`
 
14
 
 
15
+ 9 training applications (for v3.02)
 
16
 
 
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
 
21
library.
 
22
 
 
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`.
 
26
 
 
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.
 
36
 
 
37
 
 
38
Building `libtesseract` and `tesseract.exe`
 
39
===========================================
 
40
 
 
41
1. Open `C:\\BuildFolder\\tesseract-3.0x\\vs2008\\tesseract.sln` in Visual
 
42
   Studio 2008.
 
43
 
 
44
   You'll see the following projects in the :guilabel:`Solution
 
45
   Explorer` (for v3.02)::
 
46
 
 
47
      ambiguous_words
 
48
      classifier_tester
 
49
      cntraining
 
50
      combine_tessdata
 
51
      dawg2wordlist
 
52
      libtesseract302
 
53
      mftraining
 
54
      shapeclustering
 
55
      tesseract
 
56
      unicharset_extractor
 
57
      wordlist2dawg
 
58
 
 
59
2. Select the build configuration you'd like to use from the
 
60
   :guilabel:`Solution Configurations` dropdown. It lists the following
 
61
   configurations::
 
62
 
 
63
      DLL_Debug
 
64
      DLL_Release
 
65
      LIB_Debug
 
66
      LIB_Release
 
67
 
 
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
 
72
   image libraries).
 
73
 
 
74
3. Build `libtesseract` by right-clicking the
 
75
   :guilabel:`libtesseract30x` project and choosing
 
76
   :menuselection:`B&uild` from the pop-up menu.
 
77
 
 
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`.
 
83
 
 
84
   The library is named as follows (for v3.02):
 
85
 
 
86
   .. parsed-literal::
 
87
 
 
88
      static libraries:
 
89
 
 
90
         `libtesseract302-static.lib`
 
91
         `libtesseract302-static-debug.lib`
 
92
 
 
93
      DLLs:
 
94
 
 
95
         `libtesseract302.lib`  (import library)
 
96
         `libtesseract302.dll`
 
97
         `libtesseract302d.lib` (import library)
 
98
         `libtesseract302d.dll`
 
99
 
 
100
4. Build the main tesseract OCR application by right-clicking the
 
101
   :guilabel:`tesseract` project and choosing :menuselection:`B&uild`. 
 
102
 
 
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:
 
107
 
 
108
   .. parsed-literal::
 
109
 
 
110
     LIB_Release: `tesseract.exe`
 
111
     LIB_Debug:   `tesseractd.exe`
 
112
     DLL_Release: `tesseract-dll.exe`
 
113
     DLL_Debug:   `tesseract-dlld.exe`
 
114
   
 
115
 
 
116
Testing `tesseract.exe`
 
117
=======================
 
118
 
 
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
 
124
details.
 
125
 
 
126
For example, you can use the following directory structure::
 
127
 
 
128
   C:\BuildFolder\
 
129
     include\
 
130
     lib\
 
131
     tesseract-3.02\
 
132
     testing\
 
133
        tessdata\
 
134
 
 
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).
 
139
 
 
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`::
 
142
 
 
143
   liblept168d.dll
 
144
   libtesseract302d.dll
 
145
 
 
146
Copy a few test images to `C:\\BuildFolder\\testing` just to make it easy
 
147
to run test commands.
 
148
 
 
149
Test tesseract by doing something like the following::
 
150
 
 
151
   tesseractd.exe eurotext.tif eurotext
 
152
 
 
153
This will create a file called `eurotext.txt` that will contain the
 
154
result of OCRing `eurotext.tif`.
 
155
 
 
156
 
 
157
Building the training applications
 
158
==================================
 
159
 
 
160
The training related applications are built using the following
 
161
projects::
 
162
 
 
163
   ambiguous_words
 
164
   classifier_tester
 
165
   cntraining
 
166
   combine_tessdata
 
167
   dawg2wordlist
 
168
   mftraining
 
169
   shapeclustering
 
170
   unicharset_extractor
 
171
   wordlist2dawg
 
172
 
 
173
.. note::
 
174
 
 
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.
 
178
 
 
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.
 
182
 
 
183
Alternatively, you can build :bi:`everything` in the Solution by
 
184
choosing :menuselection:`&Build --> &Build Solution` (:kbd:`Ctrl+Shift+B`)
 
185
from the menu bar.
 
186
 
 
187
See http://code.google.com/p/tesseract-ocr/wiki/TrainingTesseract3 for
 
188
more information on using these applications.
 
189
 
 
190
 
 
191
.. _building-with-vc2008-express:
 
192
 
 
193
Building |Tesseractocr| with Visual C++ 2008 Express Edition
 
194
============================================================
 
195
 
 
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::
 
201
 
 
202
   Fatal error RC1015: cannot open include file 'afxres.h'
 
203
 
 
204
.. _version-resource:
 
205
 
 
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).
 
210
 
 
211
      .. image:: images/dll_properties_details_tab.png
 
212
         :align: center
 
213
         :alt: Windows 7 Properties' Details Tab
 
214
 
 
215
Unfortunately, the Express Edition doesn't include the Resource
 
216
Editor. So in all resource files::
 
217
 
 
218
   #include "afxres.h"
 
219
 
 
220
has to be changed to::
 
221
 
 
222
   #include "windows.h"
 
223
 
 
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.
 
228
 
 
229
 
 
230
..         
 
231
   Local Variables:
 
232
   coding: utf-8
 
233
   mode: rst
 
234
   indent-tabs-mode: nil
 
235
   sentence-end-double-space: t
 
236
   fill-column: 72
 
237
   mode: auto-fill
 
238
   standard-indent: 3
 
239
   tab-stop-list: (3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60)
 
240
   End: