OpenWrt Forum Archive

Topic: Building tesseract OCR package

The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi, I'm trying to compile tesseract OCR package from souce for OpenWRT which I'd like to use for CAPTCHA recognition. So far I've managed to write the following Makefile:

include $(TOPDIR)/rules.mk

PKG_NAME:=tesseract
PKG_VERSION:=2.04
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://tesseract-ocr.googlecode.com/files/
#PKG_MD5SUM:= 5b2e98da2310c71c703d4617b88a173f

include $(INCLUDE_DIR)/package.mk

define Package/tesseract
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=tesseract
  URL:=http://tesseract-ocr.googlecode.com/files/
endef

define Package/tesseract/description
OCR
endef

define Build/Configure
    $(call Build/Configure/Default)
endef

define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS) CFLAGS="$(TARGET_CFLAGS)" all
endef

define Package/tesseract/install                                       
    $(INSTALL_DIR) $(1)/usr/sbin                                 
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/tesseract $(1)/usr/sbin/
endef                                                           

$(eval $(call BuildPackage,tesseract))         


The tesseract packet is present in the 'make menuconfig' so I sign it with <M> so the packet would be build as .ipk file.
When it comes to compiling, sources are being downloaded and then I get the error after about 30s of compiling tesseract.

What might be a problem? Any Ideas?


Thanks in advance, Andrzej

rycerstwo wrote:

When it comes to compiling, sources are being downloaded and then I get the error after about 30s of compiling tesseract.

What might be a problem? Any Ideas?

Can you please post the output from the compilation? Without it , there is no way to know what causes the problem.

Hi, I've changed the linux machine that I'm compiling packages with and since then, with the same Makefile, I get

boro@boro-desktop:~/Documents/backfire$ make package/tesseract/compile V=99
make[1]: Entering directory `/home/boro/Documents/backfire'
make[2]: Entering directory `/home/boro/Documents/backfire/package/tesseract'
Makefile:37: *** missing separator.  Stop.
make[2]: Leaving directory `/home/boro/Documents/backfire/package/tesseract'
make[1]: *** [package/tesseract/compile] Error 2
make[1]: Leaving directory `/home/boro/Documents/backfire'
make: *** [package/tesseract/compile] Error 2

For that reason I'm even further away from solution than I've already been. I'll try to make it work and will let know.

What might be a reason of this error, I get it while processing of last line of Makefile: $(eval $(call BuildPackage,tesseract))

(Last edited by rycerstwo on 19 Apr 2010, 16:16)

OK, I've looked into a problem and it turns out that in some places in Makefile it is required to use TABs instead of SPACES.


I start compiling tesseract package by issuing:

$ make package/tesseract/compile V=99

Sources are getting downloaded and there's a whole bunch of compiling stuff on the screen, I'm gonna place here the last ones, relevant ones:

mips-openwrt-linux-uclibc-g++ -DHAVE_CONFIG_H -I. -I..  -I../ccutil -I../ccstruct -I../image -I../viewer -I../ccops -I../dict -I../classify -I../wordrec -I../cutil -I../textord -I/home/boro/Documents/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/include -I/home/boro/Documents/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/include -I/home/boro/Documents/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/include -I/home/boro/Documents/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/include   -Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time -fhonour-copts -msoft-float  -MT tesseractfull.o -MD -MP -MF .deps/tesseractfull.Tpo -c -o tesseractfull.o tesseractfull.cc
mv -f .deps/tesseractfull.Tpo .deps/tesseractfull.Po
ld -r -o libtesseract_full.o tesseractfull.o \
    libtesseract_main.a \
    ../textord/libtesseract_textord.a \
    ../pageseg/libtesseract_pageseg.a \
    ../wordrec/libtesseract_wordrec.a \
    ../classify/libtesseract_classify.a \
    ../dict/libtesseract_dict.a \
    ../viewer/libtesseract_viewer.a \
    ../image/libtesseract_image.a \
    ../cutil/libtesseract_cutil.a \
    ../ccstruct/libtesseract_ccstruct.a \
    ../ccutil/libtesseract_ccutil.a
ld: tesseractfull.o: Relocations in generic ELF (EM: 8)
ld: tesseractfull.o: Relocations in generic ELF (EM: 8)
ld: tesseractfull.o: Relocations in generic ELF (EM: 8)
tesseractfull.o: could not read symbols: File in wrong format
make[6]: *** [libtesseract_full.o] Error 1
make[6]: Leaving directory `/home/boro/Documents/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/tesseract-2.04/ccmain'
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory `/home/boro/Documents/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/tesseract-2.04/ccmain'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/boro/Documents/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/tesseract-2.04'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/boro/Documents/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/tesseract-2.04'
make[2]: *** [/home/boro/Documents/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/tesseract-2.04/.built] Error 2
make[2]: Leaving directory `/home/boro/Documents/backfire/package/tesseract'
make[1]: *** [package/tesseract/compile] Error 2
make[1]: Leaving directory `/home/boro/Documents/backfire'
make: *** [package/tesseract/compile] Error 2

I've also run ./configure --help in tesseract sources and there's a part:

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

The problem might me that tesseract is thinking that's being built on the other platform than it is happening in real.

(Last edited by rycerstwo on 20 Apr 2010, 18:43)

The discussion might have continued from here.