在MacOsX上为Objective C编译Tesseract-OCR 3.01(非iPhone)

时间:2012-10-22 23:31:36

标签: objective-c macos compilation ocr tesseract

我想在我的一个Macintosh应用程序中实现Tesseract OCR library,我遇到了一个我觉得自己无法解决的问题。

我必须为Objective C for Mac开发编译文件。我在网上搜索,我发现的每篇文章都有近2年的历史。我找到了一些脚本(参见下面的代码段),其中所有OLD iOs版本和仅仅替换MacOsX相关路径的iOs相关路径都不起作用。

我以前从未做过这样的事情。如果你有一个解决方案,我会非常感激,但如果你能给我一些关于在哪里看的提示,那么也将非常感激。我知道我不应该为arm架构编译,但是有很多代码段,我不知道我在做什么,我需要一点帮助...

提前致谢!

#!/bin/sh
# build_fat.sh
#
# Created by Robert Carlsen on 15.07.2009. Updated 24.9.2010
# build an arm / i386 lib of standard linux project
#
# initially configured for tesseract-ocr v2.0.4
# updated for tesseract prerelease v3
 
outdir=outdir
mkdir -p $outdir/arm $outdir/i386
 
libdirs=( api ccutil ccmain ccstruct classify cutil dict image textord training viewer wordrec )
libs=( api ccutil main ccstruct classify cutil dict image textord training viewer wordrec )
count=${#libdirs[@]}
 
make distclean
unset CPPFLAGS CFLAGS LDFLAGS CPP CXX CC CXXFLAGS DEVROOT SDKROOT LD
 
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS6.0.sdk
export CPPFLAGS=”-I$SDKROOT/usr/lib/gcc/arm-apple-darwin10/4.2.1/include/ -I$SDKROOT/usr/include/ -miphoneos-version-min=3.0″
export CFLAGS=”$CPPFLAGS -arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT”
export LDFLAGS=”-L$SDKROOT/usr/lib/”
export CXXFLAGS=”$CFLAGS”
export CPP=”$DEVROOT/usr/bin/cpp-4.2 $CPPFLAGS”
export CXX=”$DEVROOT/usr/bin/g++-4.2 $CXXFLAGS”
export CC=”$DEVROOT/usr/bin/gcc-4.2 $CFLAGS”
./configure LD=$DEVROOT/usr/bin/ld –host=arm-apple-darwin
make -j4
cp api/.libs/libtesseract_api.a libtesseract_api_armv6.a
cp ccutil/.libs/libtesseract_ccutil.a libtesseract_ccutil_armv6.a
cp ccmain/.libs/libtesseract_main.a libtesseract_main_armv6.a
cp ccstruct/.libs/libtesseract_ccstruct.a libtesseract_ccstruct_armv6.a
cp classify/.libs/libtesseract_classify.a libtesseract_classify_armv6.a
cp cutil/.libs/libtesseract_cutil.a libtesseract_cutil_armv6.a
cp dict/.libs/libtesseract_dict.a libtesseract_dict_armv6.a
cp image/.libs/libtesseract_image.a libtesseract_image_armv6.a
cp textord/.libs/libtesseract_textord.a libtesseract_textord_armv6.a
cp training/.libs/libtesseract_training.a libtesseract_training_armv6.a
cp viewer/.libs/libtesseract_viewer.a libtesseract_viewer_armv6.a
cp wordrec/.libs/libtesseract_wordrec.a libtesseract_wordrec_armv6.a

make distclean
unset CPPFLAGS CFLAGS LDFLAGS CPP CXX CC CXXFLAGS DEVROOT SDKROOT
export CFLAGS=”-arch i386 -pipe -no-cpp-precomp”
export CXXFLAGS=”$CFLAGS”
./configure
make -j4
cp api/.libs/libtesseract_api.a libtesseract_api_i386.a
cp ccutil/.libs/libtesseract_ccutil.a libtesseract_ccutil_i386.a
cp ccmain/.libs/libtesseract_main.a libtesseract_main_i386.a
cp ccstruct/.libs/libtesseract_ccstruct.a libtesseract_ccstruct_i386.a
cp classify/.libs/libtesseract_classify.a libtesseract_classify_i386.a
cp cutil/.libs/libtesseract_cutil.a libtesseract_cutil_i386.a
cp dict/.libs/libtesseract_dict.a libtesseract_dict_i386.a
cp image/.libs/libtesseract_image.a libtesseract_image_i386.a
cp textord/.libs/libtesseract_textord.a libtesseract_textord_i386.a
cp training/.libs/libtesseract_training.a libtesseract_training_i386.a
cp viewer/.libs/libtesseract_viewer.a libtesseract_viewer_i386.a
cp wordrec/.libs/libtesseract_wordrec.a libtesseract_wordrec_i386.a

$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_api_armv6.a -arch i386 libtesseract_api_i386.a -create -output libtesseract_api.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_ccutil_armv6.a -arch i386 libtesseract_ccutil_i386.a -create -output libtesseract_ccutil.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_main_armv6.a -arch i386 libtesseract_main_i386.a -create -output libtesseract_main.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_ccstruct_armv6.a -arch i386 libtesseract_ccstruct_i386.a -create -output libtesseract_ccstruct.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_classify_armv6.a -arch i386 libtesseract_classify_i386.a -create -output libtesseract_classify.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_cutil_armv6.a -arch i386 libtesseract_cutil_i386.a -create -output libtesseract_cutil.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_dict_armv6.a -arch i386 libtesseract_dict_i386.a -create -output libtesseract_dict.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_image_armv6.a -arch i386 libtesseract_image_i386.a -create -output libtesseract_image.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_textord_armv6.a -arch i386 libtesseract_textord_i386.a -create -output libtesseract_textord.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_training_armv6.a -arch i386 libtesseract_training_i386.a -create -output libtesseract_training.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_viewer_armv6.a -arch i386 libtesseract_viewer_i386.a -create -output libtesseract_viewer.a
$DEVROOT/usr/bin/lipo -arch armv6 libtesseract_wordrec_armv6.a -arch i386 libtesseract_wordrec_i386.a -create -output libtesseract_wordrec.a

unset CPPFLAGS CFLAGS LDFLAGS CPP CXX CC CXXFLAGS DEVROOT SDKROOT

1 个答案:

答案 0 :(得分:1)

我在这个主题上度过了最后几天,我设法针对 iOs SDK 5.0,4.2和Simulator i386 编译了一个可用的库。

这两个教程帮了我很多!希望他们也会帮助其他人:

how to: cross compiling libraries for ios (armv6/armv7/i386)

how to: compile and use tesseract (3.01) on ios (sdk 5)

我仍然试图让那些在MacOsX环境中工作。如果我设法完成它,我会再次发布。