fcheng00 / tesseract-ocr

Automatically exported from code.google.com/p/tesseract-ocr
Other
0 stars 1 forks source link

ambigs.cpp:273:63: error: 'strtok_r' was not declared in this scope #1288

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.compiling tesseract under cygwin
2.
3.

What is the expected output? What do you see instead?

I expect it to compile ok. Instead I get error related to strtok_r.

What version of the product are you using? 

Latest git clone of tesseract-ocr from website

On what operating system?
Windows 8
uname -m = i686
uname -r = 1.7.32(0.274/5/3)
uname -s = CYGWIN_NT-6.3-WOW64
uname -v = 2014-08-13 23:03

Please provide any additional information below.

User@HP /opt/src
$ sh tessbuild.sh
Fetching origin
ambigs.cpp: In member function 'bool 
tesseract::UnicharAmbigs::ParseAmbiguityLin                                     

                            e(int, int, int, const UNICHARSET&, char*, int*, 
UNICHAR_ID*, int*, char*, int*)                                                 

                ':
ambigs.cpp:273:63: error: 'strtok_r' was not declared in this scope
   if (!(token = strtok_r(buffer, kAmbigDelimiters, &next_token)) ||
                                                               ^
ambigs.cpp:285:63: error: 'strtok_r' was not declared in this scope
     if (!(token = strtok_r(NULL, kAmbigDelimiters, &next_token))) break;
                                                               ^
ambigs.cpp:295:61: error: 'strtok_r' was not declared in this scope
       !(token = strtok_r(NULL, kAmbigDelimiters, &next_token)) ||
                                                             ^
ambigs.cpp:308:63: error: 'strtok_r' was not declared in this scope
     if (!(token = strtok_r(NULL, kAmbigDelimiters, &next_token))) break;
                                                               ^
ambigs.cpp:329:63: error: 'strtok_r' was not declared in this scope
     if (!(token = strtok_r(NULL, kAmbigDelimiters, &next_token)) ||
                                                               ^
make[3]: *** [ambigs.lo] Error 1
make[2]: *** [install-recursive] Error 1
make[1]: *** [install-recursive] Error 1
make: *** [install-strip] Error 2

I have also posted about this on the tesseract-ocr forum. No suggestions on how 
to fix it yet.

Original issue reported on code.google.com by shreeshrii on 23 Aug 2014 at 4:32

GoogleCodeExporter commented 9 years ago
Here is the logfile.

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking --enable-graphics argument... yes
checking --enable-embedded argument... no
checking --enable-opencl argument... no
checking --enable-visibility argument... no
checking --enable-multiple-libraries argument... no
checking whether to use tessdata-prefix... yes
checking whether to enable debugging... no
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking how to print strings... printf
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i686-pc-cygwin file names to i686-pc-cygwin format... 
func_convert_file_noop
checking how to convert i686-pc-cygwin file names to toolchain format... 
func_convert_file_noop
checking for /usr/i686-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive 
import|^x86 DLL
checking for dlltool... dlltool
checking how to associate runtime and link libraries... 
func_cygming_dll_for_implib
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/i686-pc-cygwin/bin/ld.exe) supports 
shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking whether the g++ linker (/usr/i686-pc-cygwin/bin/ld.exe) supports 
shared libraries... yes
checking for g++ option to produce PIC... -DDLL_EXPORT -DPIC
checking if g++ PIC flag -DDLL_EXPORT -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/i686-pc-cygwin/bin/ld.exe) supports 
shared libraries... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether byte ordering is bigendian... no
checking if compiling with clang... no
checking whether compiler supports C++11... yes
checking for snprintf... yes
checking for library containing sem_init... none required
checking for ANSI C header files... (cached) yes
checking whether time.h and sys/time.h may both be included... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking sys/ipc.h usability... yes
checking sys/ipc.h presence... yes
checking for sys/ipc.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... no
checking whether #! works in shell scripts... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for getline... yes
checking for wchar_t... yes
checking for long long int... yes
checking for mbstate_t... yes
checking for leptonica... yes
checking for pixCreate in -llept... yes
checking leptonica version >= 1.71... yes
checking unicode/uchar.h usability... yes
checking unicode/uchar.h presence... yes
checking for unicode/uchar.h... yes
checking pango-1.0/pango/pango-features.h usability... yes
checking pango-1.0/pango/pango-features.h presence... yes
checking for pango-1.0/pango/pango-features.h... yes
checking cairo/cairo-version.h usability... yes
checking cairo/cairo-version.h presence... yes
checking for cairo/cairo-version.h... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating tesseract.pc
config.status: creating api/Makefile
config.status: creating ccmain/Makefile
config.status: creating opencl/Makefile
config.status: creating ccstruct/Makefile
config.status: creating ccutil/Makefile
config.status: creating classify/Makefile
config.status: creating cube/Makefile
config.status: creating cutil/Makefile
config.status: creating dict/Makefile
config.status: creating neural_networks/runtime/Makefile
config.status: creating textord/Makefile
config.status: creating viewer/Makefile
config.status: creating wordrec/Makefile
config.status: creating tessdata/Makefile
config.status: creating tessdata/configs/Makefile
config.status: creating tessdata/tessconfigs/Makefile
config.status: creating testing/Makefile
config.status: creating java/Makefile
config.status: creating java/com/Makefile
config.status: creating java/com/google/Makefile
config.status: creating java/com/google/scrollview/Makefile
config.status: creating java/com/google/scrollview/events/Makefile
config.status: creating java/com/google/scrollview/ui/Makefile
config.status: creating doc/Makefile
config.status: creating training/Makefile
config.status: creating config_auto.h
config.status: executing depfiles commands
config.status: executing libtool commands

Configuration is done.
You can now build and install tesseract by running:

$ make
$ sudo make install

Training tools can be build and installed (after building of tesseract) with:

$ make training
$ sudo make training-install

Original comment by shreeshrii on 23 Aug 2014 at 4:34

GoogleCodeExporter commented 9 years ago
The following comment by Fred at http://vorba.ch/2014/tesseract-cygwin.html 
helped get rid of that error. I needed to change 'configure' as described. 

However, it has thrown up another error - which I shall post in a different 
issue.

"fred • 6 months ago
I tried compiling tesseract-ocr 3.03 with the source code from SVN. After 
executing "make" the compiler said there're some functions missing. Actually 
it's a problem of cpp standard choices. Simply replacing "c++11" with "gnu++11" 
in the file "configure", then rerun this script. The problem will be solved."

Original comment by shreeshrii on 23 Aug 2014 at 6:28

GoogleCodeExporter commented 9 years ago
I can not reproduce it on msys (32bit in windows XP mode). Mingw uses[1] ported 
strtok_r from vs2010/port directory.

Your comment #2 indicates that there is problem on your site: for cygwin 
tesseract use "gnu++11" instead of "c++11"[1].

[1] 
https://code.google.com/p/tesseract-ocr/source/browse/ccutil/Makefile.am?r=3a5f6
9901310e26a958c6cb6395174368b44c99c#44
[2] 
https://code.google.com/p/tesseract-ocr/source/browse/configure.ac?r=298e31465a4
45e54defedd076217ff24b1af3fc2#412

Original comment by zde...@gmail.com on 13 Sep 2014 at 6:46

GoogleCodeExporter commented 9 years ago
Thanks, Zdenko,

It works fine now. Msys2 developers must have changed some settings. 

This is from config log from sept 1

hostname = HP
uname -m = i686
uname -r = 2.0.0(0.275/5/3)
uname -s = MINGW32_NT-6.3-WOW64
uname -v = 2014-09-01 20:59

Original comment by shreeshrii on 14 Sep 2014 at 9:49

GoogleCodeExporter commented 9 years ago
If there is need to change something for msys2 in tesseract, let responsible 
person create new issue with patch. 

Original comment by zde...@gmail.com on 14 Sep 2014 at 9:57

GoogleCodeExporter commented 9 years ago
tesseract = 3.04.00
uname -m = i686
uname -r = 2.1.0(0.287/5/3)
uname -s = CYGWIN_NT-6.1-WOW
uname -v = 2015-07-14 21:26

and

tesseract = 3.04.00
uname -m = x86_64
uname -r = 2.1.0(0.287/5/3)
uname -s = CYGWIN_NT-6.1
uname -v = 2015-07-14 21:28

I have changed this lines on file ambigs.cpp and compiled successfully:
#if defined _WIN32 || defined(__CYGWIN__)
//#ifndef __GNUC__
//#define strtok_r strtok_s
#else
#include "strtok_r.h"
//#endif  /* __GNUC__ */
#endif  /* _WIN32 __CYGWIN__*/

Original comment by vjcc...@gmail.com on 22 Jul 2015 at 2:17