title: Compiling Tesseract-OCR 3.01 for Objective C on MacOsX (Non iPhone)
body: <p>I want to implement the <a href="http://code.google.com/p/tesseract-ocr/" rel="nofollow">Tesseract OCR library</a> in one of my Macintosh applications and I'm facing a problem which I feel like I can't solve by myself.</p>
  
  <p><strong>I have to compile the files for Objective C for Mac development.</strong> 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.</p>
  
  <p>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...</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>#!/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
  </code></pre>