duncantl / Rtesseract

Interface to tesseract OCR system.
12 stars 4 forks source link

using std::string does not work #5

Closed mespe closed 7 years ago

mespe commented 7 years ago

Trying to compile Rtesseract against the latest version of Tesseract to see it if fixes some buggy behavior I am experiencing with configuration variables using 4.00alpha.

I added:

#include <string>
using std::string;

to Rtesseract.h per: https://github.com/tesseract-ocr/tesseract/issues/1045

But the string header is not being found:

RConverters.c:1:10: fatal error: string: No such file or directory

The issue appears to stem from RConverters being recognized as a C file, and hence the C++ header is not being found:

gcc -I/usr/include/R/ -DNDEBUG   -D_FORTIFY_SOURCE=2   -fpic  -O3 -mtune=native  -c RConverters.c -o RConverters.o

Renaming RConverters.c to RConverters.cc leads to the following error:

g++  -I/usr/include/R/ -DNDEBUG   -D_FORTIFY_SOURCE=2  -I/usr/include/leptonica  -I/usr/include/tesseract -I/usr/include/leptonica  -fpic  -O3 -mtune=native  -c RConverters.cc -o RConverters.o
RConverters.cc: In function ‘Rboolean IS_S4_INSTANCE(SEXP, const char*)’:
RConverters.cc:500:25: error: invalid conversion from ‘int’ to ‘Rboolean’ [-fpermissive]
  status = LOGICAL(ans)[0];
dsidavis commented 7 years ago

Yep, R will compile files with a .c extension as C, not C++ and so use the C compiler. Please git mv the file to RConverters.cc

mespe commented 7 years ago

Done - Second part of the issue stands though. Rtesseract will not compile.

dsidavis commented 7 years ago

I suspect adding an explicit cast status = (Rboolean) LOGICAL(ans)[0]; will cure the problem

mespe commented 7 years ago

Fixed by adding:

#include<string>
using std::string

To all places where baseapi.h is being included.

dsidavis commented 7 years ago

Can we close this?

mespe commented 7 years ago

If you think it needs to be re-opened, feel free. It seemed to be resolved with our work today.

dsidavis commented 7 years ago

My mistake. I was looking at a page in my browser that hadn't been refreshed and trying to be efficient in actually closing things. So I totally agree it should be closed. Just noise at this point from my end :-) We do need the matrix though of OS/compiler &version/tesseract and version/(day of week, color of clothing worn/....)

mespe commented 7 years ago

Look at Installing Rtesseract

dsidavis commented 7 years ago

Thanks. Let's close and kill this issue. Easier to do email :-)

amitdo commented 6 years ago

Tesseract is now at beta 1 stage.

This version uses std:string everywhere. USE_STD_NAMESPACE is not needed anymore.