xwal / Tesseract-OCR-iOS

Tesseract OCR iOS is a Framework for iOS8+, compiled also for armv7s and arm64. I have upgraded tesseract version to 4.1.1 release.
MIT License
45 stars 31 forks source link

Compile #3

Open winstonschen opened 5 years ago

winstonschen commented 5 years ago

This repo is so helpful because of its support for Tesseract 4.0.

I'm try to compile this again with the latest Tesseract release using Xcode 10.2 and got stuck. I'm rebuilding because many of the latest trained models do not work.

But when I followed the instructions and running make, when building Leptonica, this error appears:

../../src/gplot.c:402:18: error: 'system' is unavailable: not available on iOS

Can you please give me some guidance? Or, can you update to the latest Tesseract?

Thanks.

xwal commented 5 years ago

Hi, You need comment system function code in Leptonica project with gplot.c:402.

scubess commented 5 years ago

Hi @chaoskyme , Thanks for amazing work in tesseract 4.0. following your comment above, i tried to compile after commenting the system function code in gplot.c at line 402. It throwed me the same error in thewritefile.c:1028:14 . which i believe it needs to be commented too. But that didn't solved the problem, it throwed me error as below,

 _pixWriteStreamJp2k in liblept.a(jp2kio.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [tesseract] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2

I attached the full error for you. error.txt

Can you provide me with some advice please ?

Thank you

xwal commented 5 years ago

@scubess You need keep your Mac OS environment is clean, let the compilation process isn't reference the library of Mac. Maybe your Mac OS install webp library.

scubess commented 5 years ago

Hi @chaoskyme ,

Sorry this is my first time trying to cross compile. I am very new and am not that much clear about the compilation process. Sorry to trouble you. I still have the problem. It will so good if i got this compiled in my system. I do have webp 1.0.2 installed already. i cleaned my Mac environment and also i have tried on my other mac. It gives me same error like this,

Making all in src/lstm
Making all in src/ccmain
Making all in src/api
libtool: link: g++ -I/Users/lshiva/Current/Tesseract-OCR-iOS/TesseractOCR/tesseract-ocr/x86_64-apple-darwin/ -Qunused-arguments -arch x86_64 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk -miphoneos-version-min=7.0 -O2 -Wno-deprecated-register -std=c++11 -o tesseract tesseract-tesseractmain.o -Wl,-bind_at_load  -L/Users/lshiva/Current/Tesseract-OCR-iOS/TesseractOCR/lib -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk/usr/lib/ -L/Users/lshiva/Current/Tesseract-OCR-iOS/TesseractOCR/leptonica-1.76.0/x86_64-apple-darwin/src/.libs ./.libs/libtesseract.a -llept -lz -lpng -ljpeg -ltiff
Undefined symbols for architecture x86_64: 

...

 _pixWriteStreamJp2k in liblept.a(jp2kio.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [tesseract] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [/Users/Tesseract-OCR-iOS/TesseractOCR/tesseract-ocr/x86_64-apple-darwin//lib/libtesseract.a] Error 2

can you help me with this error please? what wrong i am doing or advise me what makes this error please ? thank you

scubess commented 5 years ago

@chaoskyme Any advice on the above error please ?

hejtmii commented 5 years ago

Hi @scubess @chaoskyme and future visitors

The problem above and one more similar can be resolved by adding --without-libwebp --without-libopenjpeg to the ../configure call for the Leptonica library in makefile (unless you really need that Leptonica API)

Anyway, I am just upgrading the library to Tesseract 4.1 while facing similar compilation issues (and more). You can find my observations here including the one above here

Current work in progress is here if anyone is interested. The demo project runs, but didn't test it in my own app yet: https://github.com/kenticomartinh/Tesseract-OCR-iOS/tree/4.1

If anyone has additional observations or knows more about topics in my notes above, let me know.

One thing I still need to investigate is why tests in the demo project are not loading in XCode.

selvaw3w commented 4 years ago

Hi @kenticomartinh , Sorry to come back to late. when I add the flags --without-libwebp --without-libopenjpeg to letonica build, it fixed the problem. Thank you

But as you mentioned , when leptonica API's called, it throw errors linking errors in libwebpio.a etc,.

Even though it built successfully, I need to call letponica APIs.

thank you so much for your help !

hejtmii commented 4 years ago

Hi @selvaw3w

That is why I said "unless you really need that Leptonica API" :-) Anyway, in your case you should probably look at how the other linked libraries are handled in the makefile, and replicate that for the libwebp library. I am not that proficient in makefiles, so I can't give you an exact advice on that.

xwal commented 4 years ago

@kenticomartinh Thanks for the solution. @winstonschen @scubess @selvaw3w I have fixed Leptonica building error, upgraded Tesseract from 4.0.0 to 4.1.1 and merged the gali8/Tesseract-OCR-iOS master . This is change log.

Upgrade tesseract 4.0.0 -> 4.1.1 Upgrade library version: jpeg: 9a -> 9d tiff: 4.0.9 -> 4.1.0 Leptonica: 1.76.0 -> 1.79.0 curl: 7.69.1 Upgrade minimum iOS version: iOS: 7.0 -> 8.0

hejtmii commented 4 years ago

Hi @chaoskyme do tests work for you? I had to make some additional cleanup of some old things that prevented them from running, see this commit.

I was also changing the default mode because TesseractOCROnly is not supported by these versions anymore. See my commit:

https://github.com/kenticomartinh/Tesseract-OCR-iOS/commit/78db08e6b881bce9b4d3b5b5478c4f3c94d846f8