我想在我的 Macintosh 应用程序之一中实现Tesseract OCR 库,但我遇到了一个我觉得自己无法解决的问题。
我必须为用于 Mac 开发的 Objective C 编译文件。我在网上搜索,我发现的每一篇文章都有近 2 年的历史。我发现了一些脚本(见下面的代码段),其中所有的旧 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