尝试按照here所述构建Tesseract 3.03培训模块。
这是在64位Win 7机器上的cygwin下。
当我运行make training
时,我得到:
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
training/pango_font_info.cpp
的上半部分如下所示:
#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"
因此,特别包括stdlib.h
。那么为什么不找到,例如setenv
?
Thx
答案 0 :(得分:0)
当我编译最新的tesseract-ocr时,我只得到第二个错误:
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);
我通过将#include "strcasestr.h"
移出#ifdef MINGW
块来修复它。
之后我收到了这个错误:
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
我通过运行cp /lib/libicui18n.dll.a /lib/libicuin.dll.a
来修复,它只是创建了ICU库的副本。