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

时间:2023-01-07 08:58:35

I want to implement the Tesseract OCR library in one of my Macintosh applications and I'm facing a problem which I feel like I can't solve by myself.

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

I have to compile the files for Objective C for Mac development. I was searching the web and every post I found was nearly 2 years old. I found some scripts (see code segment below) that where all for OLD iOs Versions and just replacing the iOs related paths by MacOsX related ones did not work.

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

I've never done something like this before. If you have a solution I would be really thankful, but if you can just give me hints on where to look it would be well appreciated either. I know that I shouldn't compile for the arm architecture, but there are so many codesegments where I don't know what I'm doing, that I need a bit of assistance...

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

Thanks in advance!

提前致谢!

#!/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 个解决方案

#1


1  

I've spent the last couple of days on this topic and I managed to compile a working library against iOs SDK 5.0, 4.2 and for Simulator i386.

我花了最近几天讨论这个主题,我设法编译了一个针对iOs SDK 5.0,4.2和Simulator i386的工作库。

These two tutorials helped me a LOT! Hope they'll help someone else too:

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

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

如何:为ios交叉编译库(armv6 / armv7 / i386)

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

如何:在ios上编译和使用tesseract(3.01)(sdk 5)

I'm still trying to get those to work in the MacOsX environment though. If I manage to get it done I'll post again.

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

#1


1  

I've spent the last couple of days on this topic and I managed to compile a working library against iOs SDK 5.0, 4.2 and for Simulator i386.

我花了最近几天讨论这个主题,我设法编译了一个针对iOs SDK 5.0,4.2和Simulator i386的工作库。

These two tutorials helped me a LOT! Hope they'll help someone else too:

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

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

如何:为ios交叉编译库(armv6 / armv7 / i386)

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

如何:在ios上编译和使用tesseract(3.01)(sdk 5)

I'm still trying to get those to work in the MacOsX environment though. If I manage to get it done I'll post again.

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