Compile tesseract for iOS SDK 6.0
Added instructions to integrate an armv7s slice in
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.
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.
If you don’t have HomeBrew already, that’s a shame. Run to this website and install it.
Then, install libtool and automake:
$ 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
$ 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:
You might want to modify
build_dependencies.sh to make
TESSERACT_LIB match the proper folders.
Now, you can build the libraries:
$ chmod +x ./build_dependencies.sh
dependencies/lib/, you’ll find
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.