Compile tesseract for iOS SDK 6.0
Update 10/25/12
Added instructions to integrate an armv7s slice in liblept.a
and libtesseract_all.a
.
Update 09/24/12
To make the iOS integration easier, I made a Github repo containing an Objective-C wrapper for Tesseract. It relies on an other repo containing tesseract & leptonica libs. Feel free to improve them !
- Objective-C wrapper: https://github.com/ldiqual/tesseract-ios
- Compiled libraries: https://github.com/ldiqual/tesseract-ios-lib
More informations about these repos on my next article.
Introduction
I had troubles while following the compiling guide from this blog: http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5/. Some dependencies are missing on a fresh Mountain Lion with Xcode 4.5, and more importantly: the build_dependencies.sh
won’t work.
Here is why: Xcode 4.5 and iOS SDK 6.0 don’t support armv6 anymore.
So here are the steps to build tesseract-ocr for iOS SDK 6.0.
Requirements
If you don’t have HomeBrew already, that’s a shame. Run to this website and install it.
Then, install libtool and automake:
1 | $ brew install libtool automake |
You should have installed ‘Command Line Tools’ after the Homebrew installation, but if you forgot: Open Xcode’s preferences, and install them from the ‘Downloads’ tab.
The build process will need libtoolize
. Just make a symlink to glibtoolize
:
1 | $ ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize |
We’re good to go.
Sources and compilation
The steps will more or less follow the tinsuke’s article, except for one thing: the build script.
Get the following sources:
- tesseract: http://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-3.01.tar.gz
- leptonica: http://www.leptonica.com/source/leptonica-1.69.tar.gz
- build_dependencies.sh: https://gist.github.com/3763217 (click on “raw” and save it to your computer)
Then, organize your folder with the following structure:
1 2 3 4 5 | ./build/ dependencies/ leptonica-1.69/ tesseract-3.01/ build_dependencies.sh |
You might want to modify build_dependencies.sh
to make LEPTON_LIB
and TESSERACT_LIB
match the proper folders.
Now, you can build the libraries:
1 2 | $ chmod +x ./build_dependencies.sh $ ./build_dependencies |
In dependencies/lib/
, you’ll find liblept.a
and libtesseract_all.a
, these are the only libraries you need so you can remove other ones. Both contain armv7 and i386 slices only, but many iOS 5 projects require an armv7s slice.
Just follow this Matt Galloway’s blog post to generate and put an armv7s slice into the libs.
Now you just have to copy dependencies/
in your Xcode Project, and follow my next article on how to use tesseract.