简体   繁体   中英

Unexpected errors when building tesseract3 training modules: “not declared in this scope”

Trying to build the Tesseract 3.03 training modules as explained here .

This is under cygwin on a 64-bit Win 7 machine.

When I run make training I get:

make[1]: Entering directory '/cygdrive/c/code/tools/tesseract-ocr-3.03-rc1/training'
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -O2 -DNDEBUG -DUSE_STD_NAMESPACE -DPANGO_ENABLE_ENGINE -I../ccmain -I../api -I../ccutil -I../ccstruct -I../viewer -I../textord -I../dict -I../classify -I../display -I../wordrec -I../cutil  -I/usr/local/include -I/usr/local/include/leptonica -D_REENTRANT -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/freetype2 -I/usr/include/libpng15   -std=c++11 -MT pango_font_info.lo -MD -MP -MF .deps/pango_font_info.Tpo -c -o pango_font_info.lo pango_font_info.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -O2 -DNDEBUG -DUSE_STD_NAMESPACE -DPANGO_ENABLE_ENGINE -I../ccmain -I../api -I../ccutil -I../ccstruct -I../viewer -I../textord -I../dict -I../classify -I../display -I../wordrec -I../cutil -I/usr/local/include -I/usr/local/include/leptonica -D_REENTRANT -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/freetype2 -I/usr/include/libpng15 -std=c++11 -MT pango_font_info.lo -MD -MP -MF .deps/pango_font_info.Tpo -c pango_font_info.cpp  -DDLL_EXPORT -DPIC -o .libs/pango_font_info.o
pango_font_info.cpp: In function 'void tesseract::InitFontconfig()':
pango_font_info.cpp:151:66: error: 'setenv' was not declared in this scope
   setenv("FONTCONFIG_PATH", FLAGS_fontconfig_tmpdir.c_str(), true);
                                  ^
pango_font_info.cpp: In member function 'bool tesseract::PangoFontInfo::ParseFontDescription(const PangoFontDescription*)':
pango_font_info.cpp:219:46: error: 'strcasestr' was not declared in this scope
   is_fraktur_ = (strcasestr(family, "Fraktur") != NULL);
                          ^
Makefile:839: recipe for target 'pango_font_info.lo' failed
make[1]: *** [pango_font_info.lo] Error 1
make[1]: Leaving directory '/cygdrive/c/code/tools/tesseract-ocr-3.03-rc1/training'
Makefile:890: recipe for target 'training' failed
make: *** [training] Error 2

The top part of training/pango_font_info.cpp looks like this:

#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif

#ifdef MINGW
// workaround for stdlib.h and putenv
#undef __STRICT_ANSI__
#include "strcasestr.h"
#endif  // MINGW
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include <algorithm>

#include "pango_font_info.h"
#include "commandlineflags.h"
#include "fileio.h"
#include "normstrngs.h"
#include "tlog.h"
#include "unichar.h"
#include "util.h"
#include "pango/pango-context.h"
#include "pango/pango-font.h"
#include "pango/pango-glyph-item.h"
#include "pango/pango-glyph.h"
#include "pango/pango-layout.h"
#include "pango/pango-utils.h"
#include "pango/pangocairo.h"
#include "pango/pangofc-font.h"

So, in particular, stdlib.h is included. So why is not finding, for example, setenv ?

Thx

When I compiled latest tesseract-ocr I only get the second error:

pango_font_info.cpp: In member function 'bool tesseract::PangoFontInfo::ParseFontDescription(const PangoFontDescription*)':
pango_font_info.cpp:219:46: error: 'strcasestr' was not declared in this scope
   is_fraktur_ = (strcasestr(family, "Fraktur") != NULL);

I fixed it by moving #include "strcasestr.h" out of the #ifdef MINGW block.

After that I got this error:

libtool: link: g++ -std=gnu++11 -Wl,-no-undefined -Wl,--as-needed -o .libs/set_unicharset_properties.exe set_unicharset_properties.o  -    L/usr/local/lib ./.libs/libtesseract_training.a ./.libs/libtesseract_tessopt.a -licuin -licuuc ../api/.libs/libtesseract.dll.a -lws2_32 /usr/local/lib/liblept.dll.a -lz -lpng -ljpeg -ltiff -lwebp -L/usr/local/lib
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licuin
collect2: error: ld returned 1 exit status
Makefile:808: recipe for target 'set_unicharset_properties.exe' failed
make[1]: *** [set_unicharset_properties.exe] Error 1
make[1]: Leaving directory '/opt/src/tesseract-ocr/training'
Makefile:890: recipe for target 'training' failed
make: *** [training] Error 2

Which I fixed by running cp /lib/libicui18n.dll.a /lib/libicuin.dll.a , which just creates a copy of the ICU library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM