~vcs-imports/tesseract-ocr/trunk

« back to all changes in this revision

Viewing changes to vs2008/doc/programming.html

  • 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
 
 
2
 
 
3
 
 
4
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
5
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
6
 
 
7
 
 
8
<html xmlns="http://www.w3.org/1999/xhtml">
 
9
  <head>
 
10
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
11
    
 
12
    <title>Programming with libtesseract &mdash; Visual Studio 2008 Developer Notes for Tesseract-OCR</title>
 
13
    
 
14
    <link rel="stylesheet" href="_static/tesseract.css" type="text/css" />
 
15
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
 
16
    
 
17
    <script type="text/javascript">
 
18
      var DOCUMENTATION_OPTIONS = {
 
19
        URL_ROOT:    '',
 
20
        VERSION:     '3.02',
 
21
        COLLAPSE_INDEX: false,
 
22
        FILE_SUFFIX: '.html',
 
23
        HAS_SOURCE:  true
 
24
      };
 
25
    </script>
 
26
    <script type="text/javascript" src="_static/jquery.js"></script>
 
27
    <script type="text/javascript" src="_static/underscore.js"></script>
 
28
    <script type="text/javascript" src="_static/doctools.js"></script>
 
29
    <script type="text/javascript" src="_static/sidebar.js"></script>
 
30
    <link rel="top" title="Visual Studio 2008 Developer Notes for Tesseract-OCR" href="index.html" />
 
31
    <link rel="next" title="Handy free tools" href="tools.html" />
 
32
    <link rel="prev" title="Building Tesseract-OCR" href="building.html" />
 
33
 
 
34
    <link href='http://fonts.googleapis.com/css?family=Droid+Serif:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
 
35
    <link href='http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold' rel='stylesheet' type='text/css'>
 
36
    <link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,400italic,700,700italic&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
 
37
 
 
38
  </head>
 
39
  <body>
 
40
    <div class="related">
 
41
      <h3>Navigation</h3>
 
42
      <ul>
 
43
        <li class="right" style="margin-right: 10px">
 
44
          <a href="tools.html" title="Handy free tools"
 
45
             accesskey="N">next</a></li>
 
46
        <li class="right" >
 
47
          <a href="building.html" title="Building Tesseract-OCR"
 
48
             accesskey="P">previous</a> |</li>
 
49
  <li><a href="http://code.google.com/p/tesseract-ocr/">Tesseract-OCR Home</a> &raquo;</li>
 
50
  
 
51
        <li><a href="index.html">Visual Studio 2008 Developer Notes</a> &raquo;</li>
 
52
 
 
53
      </ul>
 
54
    </div>  
 
55
 
 
56
    <div class="document">
 
57
      <div class="documentwrapper">
 
58
        <div class="bodywrapper">
 
59
          <div class="body">
 
60
            
 
61
  <div class="section" id="programming-with-libtesseract">
 
62
<h1>Programming with <span class="filesystem">libtesseract</span><a class="headerlink" href="#programming-with-libtesseract" title="Permalink to this headline">¶</a></h1>
 
63
<p>To use <span class="filesystem">libtesseract</span> in your own application you need to include
 
64
<strong>Leptonica</strong>’s <span class="filesystem">allheaders.h</span>, and <strong>Tesseract-OCR</strong>’s <span class="filesystem">baseapi.h</span> and
 
65
<span class="filesystem">strngs.h</span>.</p>
 
66
<p><strong>Tesseract-OCR</strong> uses <span class="filesystem">liblept</span> mainly for image I/O, but you can also use
 
67
any of <strong>Leptonica</strong>’s <em>many</em> image processing functions on <tt class="docutils literal"><span class="pre">PIX</span></tt>,
 
68
while at the same time calling <tt class="docutils literal"><span class="pre">TessBaseAPI</span></tt> methods. See the
 
69
<a class="reference external" href="http://tpgit.github.com/UnOfficialLeptDocs/">Leptonica documentation</a>
 
70
for more details.</p>
 
71
<p>There doesn&#8217;t seem to be any documentation on <span class="filesystem">api\baseapi.h</span>, but it
 
72
has extensive comments. You can also look at the <a class="reference internal" href="#apitest"><em>APITest Sample</em></a> and
 
73
<a class="reference internal" href="#apiexamples"><em>APIExamples</em></a> projects.</p>
 
74
<p>See the <a class="reference internal" href="#apitest"><em>APITest Sample</em></a> project for an example of which compiler and
 
75
linker settings you need for various build configurations. The easiest
 
76
way to begin a new application is to just make a copy of the <span class="filesystem">APITest</span>
 
77
directory. See <a class="reference internal" href="maintenance.html#copying-a-project"><em>this step</em></a> for detailed
 
78
instructions (skip the last step about adding <em class="guilabel">Project
 
79
Dependencies</em>).</p>
 
80
<p>If you want to manually set the required settings, then here&#8217;s the list
 
81
of things to do:</p>
 
82
<ol class="arabic">
 
83
<li><p class="first">Add the following <em class="guilabel">Preprocessor Definitions</em> when compiling
 
84
any files that include <span class="filesystem">baseapi.h</span> and you are linking with the
 
85
static library versions of <span class="filesystem">libtesseract</span>:</p>
 
86
<div class="highlight-none"><div class="highlight"><pre>USE_STD_NAMESPACE
 
87
</pre></div>
 
88
</div>
 
89
<p>If you are linking with the DLL versions of <span class="filesystem">libtesseract</span> instead
 
90
add:</p>
 
91
<div class="highlight-none"><div class="highlight"><pre>USE_STD_NAMESPACE;TESSDLL_IMPORTS;CCUTIL_IMPORTS;LIBLEPT_IMPORTS
 
92
</pre></div>
 
93
</div>
 
94
</li>
 
95
<li><p class="first">Be sure to add the following to <em class="guilabel">Additional Include
 
96
Directories</em>:</p>
 
97
<div class="highlight-none"><div class="highlight"><pre>C:\BuildFolder\include
 
98
C:\BuildFolder\include\leptonica
 
99
 
 
100
C:\BuildFolder\include\tesseract or
 
101
 
 
102
&lt;tesseract-3.0x dir&gt; (all its sub-directories that contain header files)
 
103
</pre></div>
 
104
</div>
 
105
</li>
 
106
<li><p class="first">Add <span class="filesystem">C:\BuildFolder\lib</span> to your <em class="guilabel">Additional Library
 
107
Directories</em>.</p>
 
108
</li>
 
109
<li><p class="first">In the <span class="filesystem">C:\BuildFolder\include</span> directory are two Visual Studio
 
110
Property Sheet files:</p>
 
111
<div class="highlight-none"><div class="highlight"><pre>tesseract_versionnumbers.vsprops
 
112
leptonica_versionnumbers.vsprops
 
113
</pre></div>
 
114
</div>
 
115
<p>Using <span class="filesystem">tesseract_versionnumbers.vsprops</span> (which automatically inherits
 
116
<span class="filesystem">leptonica_versionnumbers.vsprops</span>) can make it easier to specify the
 
117
libraries you need to import. For example, when creating a staticly
 
118
linked debug executable you can say:</p>
 
119
<div class="highlight-none"><div class="highlight"><pre>zlib$(ZLIB_VERSION)-static-mtdll-debug.lib
 
120
libpng$(LIBPNG_VERSION)-static-mtdll-debug.lib
 
121
libjpeg$(LIBJPEG_VERSION)-static-mtdll-debug.lib
 
122
giflib$(GIFLIB_VERSION)-static-mtdll-debug.lib
 
123
libtiff$(LIBTIFF_VERSION)-static-mtdll-debug.lib
 
124
liblept$(LIBLEPT_VERSION)-static-mtdll-debug.lib
 
125
libtesseract$(LIBTESS_VERSION)-static-debug.lib
 
126
</pre></div>
 
127
</div>
 
128
<p>to make your application less dependent on library version numbers.</p>
 
129
<p>To add the Property Sheet to a Project, open its <em class="guilabel">Properties
 
130
Pages</em> Dialog, and set the <em class="guilabel">Configuration Properties |
 
131
General | Inherited Project Property Sheets</em> item to:</p>
 
132
<div class="highlight-none"><div class="highlight"><pre>..\..\..\include\tesseract_versionnumbers.vsprops
 
133
</pre></div>
 
134
</div>
 
135
<p>Choosing <em class="menuselection"><span class="accelerator">V</span>iew ‣ Oth<span class="accelerator">e</span>r Windows ‣ Property
 
136
<span class="accelerator">M</span>anager</em> from the menubar will let you see the Properties attached
 
137
to each Project&#8217;s configurations.</p>
 
138
</li>
 
139
</ol>
 
140
<div class="admonition note">
 
141
<p class="first admonition-title">Note</p>
 
142
<p class="last">The DLL versions of <span class="filesystem">libtesseract</span> currently only export the
 
143
<tt class="docutils literal"><span class="pre">TessBaseAPI</span></tt> C++ class from <span class="filesystem">baseapi.h</span>, there is no C function
 
144
interface yet.</p>
 
145
</div>
 
146
<div class="admonition note">
 
147
<p class="first admonition-title">Note</p>
 
148
<p class="last">The DLL versions of <span class="filesystem">libtesseract</span> currently only export the
 
149
<tt class="docutils literal"><span class="pre">TessBaseAPI</span></tt> and <tt class="docutils literal"><span class="pre">STRING</span></tt> classes. In theory, all you need is
 
150
are those classes. However, if you find yourself having to manipulate
 
151
other &#8220;internal&#8221; tesseract objects then you currently have to link
 
152
with the <strong>static library</strong> versions of <span class="filesystem">libtesseract</span>.</p>
 
153
</div>
 
154
<div class="admonition warning">
 
155
<p class="first admonition-title">Warning</p>
 
156
<p class="last">The Release versions of <span class="filesystem">liblept</span>, by design, <em>never</em> print out any
 
157
possibly helpful messages to the console. Therefore, it is highly
 
158
recommended that you do your initial development using the Debug
 
159
versions of <span class="filesystem">liblept</span>. See <a class="reference external" href="http://tpgit.github.com/UnOfficialLeptDocs/leptonica/README.html#compile-time-control-over-stderr-output">Compile-time control over stderr output</a>
 
160
for details.</p>
 
161
</div>
 
162
<p>&lt;&lt;&lt;Need to add the URL of the zip file that contains include &amp; lib
 
163
directory contents for those people who don&#8217;t want to build libtesseract
 
164
themselves&gt;&gt;&gt;</p>
 
165
<div class="section" id="debugging-tips">
 
166
<h2>Debugging Tips<a class="headerlink" href="#debugging-tips" title="Permalink to this headline">¶</a></h2>
 
167
<p>Before debugging programs written with <span class="filesystem">libtesseract</span>, you should first
 
168
download the latest Leptonica sources (currently
 
169
<span class="filesystem">leptonica-1.68.tar.gz</span>) and VS2008 source package (<span class="filesystem">vs2008-1.68.zip</span>)
 
170
from:</p>
 
171
<ul>
 
172
<li><p class="first"><a class="reference external" href="http://code.google.com/p/leptonica/downloads/detail?name=leptonica-1.68.tar.gz">http://code.google.com/p/leptonica/downloads/detail?name=leptonica-1.68.tar.gz</a></p>
 
173
</li>
 
174
<li><p class="first"><a class="reference external" href="http://code.google.com/p/leptonica/downloads/detail?name=vs2008-1.68.zip">http://code.google.com/p/leptonica/downloads/detail?name=vs2008-1.68.zip</a></p>
 
175
</li>
 
176
</ul>
 
177
<p>Unpack them to <span class="filesystem">C:\BuildFolder</span> to get the following directory structure:</p>
 
178
<div class="highlight-none"><div class="highlight"><pre>C:\BuildFolder\
 
179
  include\
 
180
  lib\
 
181
  leptonica-1.68\
 
182
     vs2008\
 
183
  tesseract-3.02\
 
184
     vs2008\
 
185
  testing\
 
186
     tessdata\
 
187
</pre></div>
 
188
</div>
 
189
<p>(see <a class="reference external" href="http://tpgit.github.com/UnOfficialLeptDocs/vs2008/building-liblept.html">Building the liblept library</a>
 
190
for more information)</p>
 
191
<p><strong>Tesseract-OCR</strong> uses <strong>Leptonica</strong> &#8220;under the hood&#8221; for all (most? some?)
 
192
of its image processing operations. Having the source available (and
 
193
compiling it in debug mode) will make it easier to see what&#8217;s really
 
194
going on.</p>
 
195
<p>You might want to add
 
196
<span class="filesystem">C:\BuildFolder\leptonica-1.68\vs2008\leptonica.vcproj</span> and
 
197
<span class="filesystem">C:\BuildFolder\tesseract-3.02\vs2008\libtesseract\libtesseract.vcproj</span>
 
198
to your solution by right-clicking it and choosing <em class="menuselection">A<span class="accelerator">d</span>d ‣
 
199
<span class="accelerator">E</span>xisting Project...</em>. This seems to make VS2008&#8217;s Intellisense <a class="reference external" href="http://tpgit.github.com/UnOfficialLeptDocs/vs2008/building-other-programs.html#intellisense-and-liblept">work
 
200
better</a>
 
201
when finding &#8220;external&#8221; source files.</p>
 
202
<p>Definitely create a <tt class="docutils literal"><span class="pre">TESSDATA_PREFIX``x</span> <span class="pre">environment</span> <span class="pre">variable</span> <span class="pre">so</span> <span class="pre">that</span> <span class="pre">it</span>
 
203
<span class="pre">contains</span> <span class="pre">the</span> <span class="pre">absolute</span> <span class="pre">path</span> <span class="pre">of</span> <span class="pre">the</span> <span class="pre">directory</span> <span class="pre">that</span> <span class="pre">contains</span> <span class="pre">the</span>
 
204
<span class="pre">``tessdata</span></tt> directory. Otherwise you&#8217;ll have to put a <tt class="docutils literal"><span class="pre">tessdata</span></tt>
 
205
directory in every temporary build folder which quickly becomes painful
 
206
(especially since tessdata has gotten very big &#8212; 600MB!).</p>
 
207
</div>
 
208
<div class="section" id="apitest-sample">
 
209
<span id="apitest"></span><h2>APITest Sample<a class="headerlink" href="#apitest-sample" title="Permalink to this headline">¶</a></h2>
 
210
<p>The <em class="guilabel">APITest</em> Solution contains the minimal settings needed to
 
211
link with <span class="filesystem">libtesseract</span>. It demonstrates the typical situation, where
 
212
the &#8220;external&#8221; application&#8217;s source files reside <em>outside</em> of the
 
213
<span class="filesystem">tesseract-3.0x</span> directory tree.</p>
 
214
<p>To build the <span class="filesystem">vs2008\APITest</span> Solution, first copy it to your
 
215
<span class="filesystem">C:\BuildFolder</span> directory. This should now look like:</p>
 
216
<div class="highlight-none"><div class="highlight"><pre>C:\BuildFolder\
 
217
 
 
218
  include\
 
219
     leptonica\
 
220
     tesseract\
 
221
 
 
222
     leptonica_versionnumbers.vsprops
 
223
     tesseract_versionnumbers.vsprops
 
224
 
 
225
  lib\
 
226
     giflib416-static-mtdll-debug.lib
 
227
     giflib416-static-mtdll.lib
 
228
     libjpeg8c-static-mtdll-debug.lib
 
229
     libjpeg8c-static-mtdll.lib
 
230
     liblept168-static-mtdll-debug.lib
 
231
     liblept168-static-mtdll.lib
 
232
     liblept168.dll
 
233
     liblept168.lib
 
234
     liblept168d.dll
 
235
     liblept168d.lib
 
236
     libpng143-static-mtdll-debug.lib
 
237
     libpng143-static-mtdll.lib
 
238
     libtesseract302.dll
 
239
     libtesseract302.lib
 
240
     libtesseract302d.dll
 
241
     libtesseract302d.lib
 
242
     libtesseract302-static.lib
 
243
     libtesseract302-static-debug.lib
 
244
     libtiff394-static-mtdll-debug.lib
 
245
     libtiff394-static-mtdll.lib
 
246
     zlib125-static-mtdll-debug.lib
 
247
     zlib125-static-mtdll.lib
 
248
 
 
249
  tesseract-3.02\
 
250
 
 
251
  APITest\
 
252
     baseapitester\
 
253
        baseapitester.cpp
 
254
        baseapitester.rc
 
255
        baseapitester.vcproj
 
256
        resource.h
 
257
        stdafx.cpp
 
258
        stdafx.h
 
259
        targetver.h
 
260
     APITest.sln
 
261
</pre></div>
 
262
</div>
 
263
<p>The <em class="guilabel">APITest</em> contains just the <em class="guilabel">baseapitester</em>
 
264
project. This was created using the VS2008 <em class="guilabel">Win32 Console
 
265
Application</em> Project Wizard and then just copying most of
 
266
<span class="filesystem">tesseractmain.cpp</span> and making minor edits. Its settings correctly refer
 
267
to the &#8220;public&#8221; <span class="filesystem">include</span> and <span class="filesystem">lib</span> directories using relative paths.</p>
 
268
<p>It assumes that the <span class="filesystem">C:\BuildFolder\include</span> directory has been
 
269
properly setup. See <a class="reference internal" href="setup.html#copying-headers"><em>this</em></a> for more details.</p>
 
270
<p>The <span class="filesystem">C:\BuildFolder\lib</span> directory will automatically get
 
271
<span class="filesystem">libtesseract</span> copied to it whenever it is built.</p>
 
272
<p>The <span class="filesystem">include\tesseract_versionnumbers.vsprops</span> Property Sheet is used
 
273
to avoid explicit library version number dependencies. Precompiled
 
274
headers are used. <em class="guilabel">LIB_Release</em>, <em class="guilabel">LIB_Debug</em>,
 
275
<em class="guilabel">DLL_Release</em>, and <em class="guilabel">DLL_Debug</em> build configurations
 
276
are supported.</p>
 
277
<p>The following are the compiler command lines and linker options
 
278
used. See <a class="reference external" href="http://msdn.microsoft.com/en-us/library/9s7c9wdw(v=vs.90).aspx">Compiling a C/C++ Program | Compiler Options</a> for a
 
279
detailed explanation of these options.</p>
 
280
<p id="apitest-lib-release"><em class="guilabel">LIB_Release</em> C/C++ <em class="guilabel">Command Line</em>:</p>
 
281
<div class="highlight-none"><div class="highlight"><pre>/O2
 
282
/I &quot;.&quot; /I &quot;..\..\include&quot; /I &quot;..\..\include\leptonica&quot;
 
283
/I &quot;..\..\include\tesseract&quot;
 
284
/D &quot;WIN32&quot; /D &quot;_WINDOWS&quot; /D &quot;NDEBUG&quot;
 
285
/D &quot;USE_STD_NAMESPACE&quot; /D &quot;_MBCS&quot;
 
286
/FD /EHsc /MD /Yc&quot;stdafx.h&quot;
 
287
/Fp&quot;LIB_Release\baseapitester.pch&quot; /Fo&quot;LIB_Release\\&quot;
 
288
/Fd&quot;LIB_Release\vc90.pdb&quot;
 
289
/W3 /nologo /c
 
290
/wd4244 /wd4305 /wd4018 /wd4267 /wd4996 /wd4800 /wd4005 /wd4355 /wd4099 /wd4566
 
291
/errorReport:prompt
 
292
</pre></div>
 
293
</div>
 
294
<p><em class="guilabel">LIB_Release</em> Linker <em class="guilabel">Additional Dependencies</em>:</p>
 
295
<div class="highlight-none"><div class="highlight"><pre>ws2_32.lib
 
296
user32.lib
 
297
zlib$(ZLIB_VERSION)-static-mtdll.lib
 
298
libpng$(LIBPNG_VERSION)-static-mtdll.lib
 
299
libjpeg$(LIBJPEG_VERSION)-static-mtdll.lib
 
300
giflib$(GIFLIB_VERSION)-static-mtdll.lib
 
301
libtiff$(LIBTIFF_VERSION)-static-mtdll.lib
 
302
liblept$(LIBLEPT_VERSION)-static-mtdll.lib
 
303
libtesseract$(LIBTESS_VERSION)-static.lib
 
304
</pre></div>
 
305
</div>
 
306
<p><em class="guilabel">LIB_Debug</em> C/C++ <em class="guilabel">Command Line</em>:</p>
 
307
<div class="highlight-none"><div class="highlight"><pre>/Od
 
308
/I &quot;.&quot; /I &quot;..\..\include&quot; /I &quot;..\..\include\leptonica&quot;
 
309
/I &quot;..\..\include\tesseract&quot;
 
310
/D &quot;WIN32&quot; /D &quot;_WINDOWS&quot; /D &quot;_DEBUG&quot;
 
311
/D &quot;USE_STD_NAMESPACE&quot; /D &quot;_MBCS&quot;
 
312
/FD /EHsc /RTC1 /MDd /Yc&quot;stdafx.h&quot;
 
313
/Fp&quot;LIB_Debug\baseapitesterd.pch&quot; /Fo&quot;LIB_Debug\\&quot;
 
314
/Fd&quot;LIB_Debug\vc90.pdb&quot;
 
315
/W3 /nologo /c /Z7
 
316
/wd4244 /wd4305 /wd4018 /wd4267 /wd4996 /wd4800 /wd4005 /wd4355 /wd4099 /wd4566
 
317
/errorReport:prompt
 
318
</pre></div>
 
319
</div>
 
320
<p><em class="guilabel">LIB_Debug</em> Linker <em class="guilabel">Additional Dependencies</em>:</p>
 
321
<div class="highlight-none"><div class="highlight"><pre>ws2_32.lib
 
322
user32.lib
 
323
zlib$(ZLIB_VERSION)-static-mtdll-debug.lib
 
324
libpng$(LIBPNG_VERSION)-static-mtdll-debug.lib
 
325
libjpeg$(LIBJPEG_VERSION)-static-mtdll-debug.lib
 
326
giflib$(GIFLIB_VERSION)-static-mtdll-debug.lib
 
327
libtiff$(LIBTIFF_VERSION)-static-mtdll-debug.lib
 
328
liblept$(LIBLEPT_VERSION)-static-mtdll-debug.lib
 
329
libtesseract$(LIBTESS_VERSION)-static-debug.lib
 
330
</pre></div>
 
331
</div>
 
332
<p><em class="guilabel">DLL_Release</em> C/C++ <em class="guilabel">Command Line</em>:</p>
 
333
<div class="highlight-none"><div class="highlight"><pre>/O2
 
334
/I &quot;.&quot; /I &quot;..\..\include&quot; /I &quot;..\..\include\leptonica&quot;
 
335
/I &quot;..\..\include\tesseract&quot;
 
336
/D &quot;WIN32&quot; /D &quot;_WINDOWS&quot; /D &quot;NDEBUG&quot;
 
337
/D &quot;USE_STD_NAMESPACE&quot; /D &quot;_MBCS&quot;
 
338
/D &quot;TESSDLL_IMPORTS&quot; /D &quot;CCUTIL_IMPORTS&quot; /D &quot;LIBLEPT_IMPORTS&quot;
 
339
/FD /EHsc /MD /Yc&quot;stdafx.h&quot;
 
340
/Fp&quot;DLL_Release\baseapitester-dll.pch&quot; /Fo&quot;DLL_Release\\&quot;
 
341
/Fd&quot;DLL_Release\vc90.pdb&quot;
 
342
/W3 /nologo /c
 
343
/wd4244 /wd4305 /wd4018 /wd4267 /wd4996 /wd4800 /wd4005 /wd4355 /wd4099 /wd4566
 
344
/errorReport:prompt
 
345
</pre></div>
 
346
</div>
 
347
<p><em class="guilabel">DLL_Release</em> Linker <em class="guilabel">Additional Dependencies</em>:</p>
 
348
<div class="highlight-none"><div class="highlight"><pre>ws2_32.lib
 
349
user32.lib
 
350
liblept$(LIBLEPT_VERSION).lib
 
351
libtesseract$(LIBTESS_VERSION).lib
 
352
</pre></div>
 
353
</div>
 
354
<p><em class="guilabel">DLL_Debug</em> C/C++ <em class="guilabel">Command Line</em>:</p>
 
355
<div class="highlight-none"><div class="highlight"><pre>/Od
 
356
/I &quot;.&quot; /I &quot;..\..\include&quot; /I &quot;..\..\include\leptonica&quot;
 
357
/I &quot;..\..\include\tesseract&quot;
 
358
/D &quot;WIN32&quot; /D &quot;_WINDOWS&quot; /D &quot;_DEBUG&quot;
 
359
/D &quot;USE_STD_NAMESPACE&quot; /D &quot;_MBCS&quot;
 
360
/D &quot;TESSDLL_IMPORTS&quot; /D &quot;CCUTIL_IMPORTS&quot; /D &quot;LIBLEPT_IMPORTS&quot;
 
361
/FD /EHsc /RTC1 /MDd /Yc&quot;stdafx.h&quot;
 
362
/Fp&quot;DLL_Debug\baseapitester-dlld.pch&quot; /Fo&quot;DLL_Debug\\&quot;
 
363
/Fd&quot;DLL_Debug\vc90.pdb&quot;
 
364
/W3 /nologo /c /Z7
 
365
/wd4244 /wd4305 /wd4018 /wd4267 /wd4996 /wd4800 /wd4005 /wd4355 /wd4099 /wd4566
 
366
/errorReport:prompt
 
367
</pre></div>
 
368
</div>
 
369
<p><em class="guilabel">DLL_Debug</em> Linker <em class="guilabel">Additional Dependencies</em>:</p>
 
370
<div class="highlight-none"><div class="highlight"><pre>ws2_32.lib
 
371
user32.lib
 
372
liblept$(LIBLEPT_VERSION)d.lib
 
373
libtesseract$(LIBTESS_VERSION)d.lib
 
374
</pre></div>
 
375
</div>
 
376
</div>
 
377
<div class="section" id="apiexamples">
 
378
<span id="id1"></span><h2>APIExamples<a class="headerlink" href="#apiexamples" title="Permalink to this headline">¶</a></h2>
 
379
<p>&lt;&lt;&lt;NEEDS WORK&gt;&gt;&gt;</p>
 
380
<p>Currently two Projects are in this solution:</p>
 
381
<ul>
 
382
<li><p class="first">preprocessing &#8211; Demonstrates how to use <strong>Leptonica</strong>’s image
 
383
processing functions to clean up images <em>before</em> calling
 
384
<tt class="docutils literal"><span class="pre">TessBaseAPI::SetImage()</span></tt>.</p>
 
385
</li>
 
386
<li><p class="first">getinfo &#8211; Demonstrates calling various <tt class="docutils literal"><span class="pre">TessBaseAPI</span></tt> methods to get
 
387
back information on the OCR process.</p>
 
388
</li>
 
389
</ul>
 
390
</div>
 
391
<div class="section" id="tesseractocr-preprocessor-definitions">
 
392
<h2><strong>Tesseract-OCR</strong> preprocessor definitions<a class="headerlink" href="#tesseractocr-preprocessor-definitions" title="Permalink to this headline">¶</a></h2>
 
393
<dl class="docutils">
 
394
<dt><tt class="docutils literal"><span class="pre">HAVE_CONFIG_H</span></tt></dt>
 
395
<dd><p class="first">Only defined when building under Linux. This causes the inclusion of
 
396
<span class="filesystem">config_auto.h</span>, which is only auto-generated during the <span class="filesystem">./configure</span>
 
397
process and thus <em>not</em> visible on Windows.</p>
 
398
<p class="last">This is what sets the <tt class="docutils literal"><span class="pre">VERSION</span></tt> macro (and lots of other
 
399
configuration related macros).</p>
 
400
</dd>
 
401
<dt><tt class="docutils literal"><span class="pre">TESSDLL_EXPORTS</span></tt></dt>
 
402
<dd>Only used when <em>building</em> DLL versions of <span class="filesystem">libtesseract</span>.</dd>
 
403
<dt><tt class="docutils literal"><span class="pre">TESSDLL_IMPORTS</span></tt></dt>
 
404
<dd><p class="first">Should be defined when building apps that link to a DLL version of
 
405
<span class="filesystem">libtesseract</span>. Used as follows in <span class="filesystem">baseapi.h</span>:</p>
 
406
<div class="highlight-none"><div class="highlight"><pre>#ifdef TESSDLL_EXPORTS
 
407
#define TESSDLL_API __declspec(dllexport)
 
408
#elif defined(TESSDLL_IMPORTS)
 
409
#define TESSDLL_API __declspec(dllimport)
 
410
#else
 
411
#define TESSDLL_API
 
412
#endif
 
413
</pre></div>
 
414
</div>
 
415
<p class="last">If you don&#8217;t define this then you&#8217;ll get &#8220;undefined external symbol&#8221;
 
416
errors.</p>
 
417
</dd>
 
418
<dt><tt class="docutils literal"><span class="pre">TESSDLL_API</span></tt></dt>
 
419
<dd>Used to mark classes for export (visibility) in DLL versions of
 
420
<span class="filesystem">libtesseract</span>. Currently <em>only</em> used with the <tt class="docutils literal"><span class="pre">TestBaseAPI</span></tt> class.</dd>
 
421
<dt><tt class="docutils literal"><span class="pre">CCUTIL_EXPORTS</span></tt></dt>
 
422
<dd>Only used when <em>building</em> DLL versions of <span class="filesystem">libtesseract</span>.</dd>
 
423
<dt><tt class="docutils literal"><span class="pre">CCUTIL_IMPORTS</span></tt></dt>
 
424
<dd><p class="first">Should be defined when building apps that link to a DLL version of
 
425
<span class="filesystem">libtesseract</span>. Used as follows in <span class="filesystem">strngs.h</span>:</p>
 
426
<div class="highlight-none"><div class="highlight"><pre>#ifdef CCUTIL_EXPORTS
 
427
#define CCUTIL_API __declspec(dllexport)
 
428
#elif defined(CCUTIL_IMPORTS)
 
429
#define CCUTIL_API __declspec(dllimport)
 
430
#else
 
431
#define CCUTIL_API
 
432
#endif
 
433
</pre></div>
 
434
</div>
 
435
<p class="last">If you don&#8217;t define this then you&#8217;ll get &#8220;undefined external symbol STRING&#8221;
 
436
errors.</p>
 
437
</dd>
 
438
<dt><tt class="docutils literal"><span class="pre">LIBLEPT_IMPORTS</span></tt></dt>
 
439
<dd><p class="first">Should be defined when building apps that link to a DLL version of
 
440
<strong>Leptonica</strong>. Used as follows in environ.h:</p>
 
441
<div class="highlight-none"><div class="highlight"><pre>#if defined(LIBLEPT_EXPORTS) || defined(LEPTONLIB_EXPORTS)
 
442
#define LEPT_DLL __declspec(dllexport)
 
443
#elif defined(LIBLEPT_IMPORTS) || defined(LEPTONLIB_IMPORTS)
 
444
#define LEPT_DLL __declspec(dllimport)
 
445
#else
 
446
#define LEPT_DLL
 
447
#endif
 
448
</pre></div>
 
449
</div>
 
450
<p class="last">If you don&#8217;t define this then you&#8217;ll get &#8220;undefined external symbol&#8221;
 
451
errors.</p>
 
452
</dd>
 
453
<dt><tt class="docutils literal"><span class="pre">USE_STD_NAMESPACE</span></tt></dt>
 
454
<dd><p class="first">Causes the following to be done:</p>
 
455
<div class="last highlight-none"><div class="highlight"><pre>#ifdef USE_STD_NAMESPACE
 
456
using std::string;
 
457
using std::vector;
 
458
#endif
 
459
</pre></div>
 
460
</div>
 
461
</dd>
 
462
<dt><tt class="docutils literal"><span class="pre">_WIN32</span></tt></dt>
 
463
<dd><p class="first">Used to indicate that the build target is Windows 32-bit or
 
464
64-bit (<tt class="docutils literal"><span class="pre">WIN32</span></tt> and <tt class="docutils literal"><span class="pre">WINDOWS</span></tt> are also added by the New Project
 
465
Wizards).</p>
 
466
<p class="last">See <a class="reference external" href="http://msdn.microsoft.com/en-us/library/b0084kay(v=vs.90).aspx">C/C+ Preprocessor Reference | The Preprocessor | Macros |
 
467
Predefined Macros</a> for
 
468
the complete list for Visual Studio 2008.</p>
 
469
</dd>
 
470
<dt><tt class="docutils literal"><span class="pre">_MSC_VER</span></tt></dt>
 
471
<dd>Used to check specifically for building with the VC++ compiler (as
 
472
opposed to the MinGW gcc compiler).</dd>
 
473
<dt><tt class="docutils literal"><span class="pre">_USRDLL</span></tt></dt>
 
474
<dd>Only defined when building the DLL versions of <span class="filesystem">libtesseract</span>.</dd>
 
475
<dt><tt class="docutils literal"><span class="pre">_MBCS</span></tt></dt>
 
476
<dd>Automatically defined when <em class="guilabel">Configuration Properties |
 
477
General | Character Set</em> is set to <em class="guilabel">Use Multi-Byte
 
478
Character Set</em>.</dd>
 
479
<dt><tt class="docutils literal"><span class="pre">DLLSYM</span></tt></dt>
 
480
<dd><a class="reference external" href="http://groups.google.com/group/tesseract-dev/msg/5e0f7f7fab27b463">Obsolete</a>
 
481
and can be ignored.</dd>
 
482
</dl>
 
483
</div>
 
484
</div>
 
485
 
 
486
 
 
487
          </div>
 
488
        </div>
 
489
      </div>
 
490
      <div class="sphinxsidebar">
 
491
        <div class="sphinxsidebarwrapper">
 
492
 
 
493
 
 
494
<ul class="current">
 
495
<li class="toctree-l1"><a class="reference internal" href="overview.html">Overview</a></li>
 
496
<li class="toctree-l1"><a class="reference internal" href="setup.html">Setting up <strong>Tesseract-OCR</strong></a></li>
 
497
<li class="toctree-l1"><a class="reference internal" href="building.html">Building <strong>Tesseract-OCR</strong></a></li>
 
498
<li class="toctree-l1 current"><a class="current reference internal" href="">Programming with <span class="filesystem">libtesseract</span></a><ul>
 
499
<li class="toctree-l2"><a class="reference internal" href="#debugging-tips">Debugging Tips</a></li>
 
500
<li class="toctree-l2"><a class="reference internal" href="#apitest-sample">APITest Sample</a></li>
 
501
<li class="toctree-l2"><a class="reference internal" href="#apiexamples">APIExamples</a></li>
 
502
<li class="toctree-l2"><a class="reference internal" href="#tesseractocr-preprocessor-definitions"><strong>Tesseract-OCR</strong> preprocessor definitions</a></li>
 
503
</ul>
 
504
</li>
 
505
<li class="toctree-l1"><a class="reference internal" href="tools.html">Handy free tools</a></li>
 
506
<li class="toctree-l1"><a class="reference internal" href="maintenance.html">Maintaining the VS2008 directory</a></li>
 
507
<li class="toctree-l1"><a class="reference internal" href="vs2010-notes.html">Using Visual Studio 2010</a></li>
 
508
<li class="toctree-l1"><a class="reference internal" href="versions.html">Version Notes</a></li>
 
509
</ul>
 
510
 
 
511
 
 
512
<div id="searchbox" style="display: none">
 
513
  <h3>Quick search</h3>
 
514
    <form class="search" action="search.html" method="get">
 
515
      <input type="text" name="q" />
 
516
      <input type="submit" value="Go" />
 
517
      <input type="hidden" name="check_keywords" value="yes" />
 
518
      <input type="hidden" name="area" value="default" />
 
519
    </form>
 
520
    <p class="searchtip" style="font-size: 90%">
 
521
    Enter search terms or a module, class or function name.
 
522
    </p>
 
523
</div>
 
524
<script type="text/javascript">$('#searchbox').show(0);</script>
 
525
        </div>
 
526
      </div>
 
527
      <div class="clearer"></div>
 
528
    </div>
 
529
    <div class="related">
 
530
      <h3>Navigation</h3>
 
531
      <ul>
 
532
        <li class="right" style="margin-right: 10px">
 
533
          <a href="tools.html" title="Handy free tools"
 
534
             >next</a></li>
 
535
        <li class="right" >
 
536
          <a href="building.html" title="Building Tesseract-OCR"
 
537
             >previous</a> |</li>
 
538
  <li><a href="http://code.google.com/p/tesseract-ocr/">Tesseract-OCR Home</a> &raquo;</li>
 
539
  
 
540
        <li><a href="index.html">Visual Studio 2008 Developer Notes</a> &raquo;</li>
 
541
 
 
542
      </ul>
 
543
    </div>
 
544
    <div class="footer">
 
545
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
 
546
    </div>
 
547
  </body>
 
548
</html>
 
 
b'\\ No newline at end of file'