tesserocr: Latest tesseract (4.0) failed to build tesserocr

ON Ubuntu 14.04,Python 2.7

when I git the tesserocr, pip installed. then appear the follow infos:

.....
{'TESSERACT_VERSION': 262144}, 

 In file included from tesserocr.cpp:309:0:
    /usr/local/include/tesseract/unichar.h:164:10: error: ‘string’ does not name a type
       static string UTF32ToUTF8(const std::vector<char32>& str32);

In file included from /usr/local/include/tesseract/osdetect.h:24:0,
                     from tesserocr.cpp:321:
    /usr/local/include/tesseract/unicharset.h:241:10: error: ‘string’ does not name a type
       static string CleanupString(const char* utf8_str) {
.....

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 27 (16 by maintainers)

Most upvoted comments

The correct directive is -DUSE_STD_NAMESPACE (see tesseract-ocr/tesseract#1045). You should be able to install the current tesserocr version by adding CPPFLAGS=-DUSE_STD_NAMESPACE prefix to the installation command.

I was able to install tesserocr after replacing string with std::string in /usr/local/include/tesseract/unicharset.h and /usr/local/include/tesseract/unichar.h.

Is this a change after this release?

Yes.

I didn’t say your code will fail to compile with newer tesseract… Still, c8464d1 is not necessary anymore.

Tesseract is now at beta 1 stage.

This version uses std:string everywhere. USE_STD_NAMESPACE is not needed anymore. @sirfz, you can revert c8464d13a.

thanks @sirfz At last I was able to build correctly tesserocr replacing string with std::string in /usr/local/include/tesseract/unicharset.h and /usr/local/include/tesseract/unichar.h

I fixed use this method:

  1. git clone this source code
  2. pip install .