Hi Shree

Sorry for the delay in replying but I'm struggling to get a successful 
build now.  I'm attaching my shell script for you to look at but the 
failure seems to be related to aclocal being called inside autogen.sh.

To be honest I'm not confident that things are building OK elsewhere as I 
see a variety of error and warning messages appear even though the relevant 
script finishes with "success"! I'm not a C/C+ etc coder, I do all my 
programming using LiveCode.  I'm just trying to get a reliable build of a 
portable version of Tesseract that I can drive through a command-line 
interface.  The OCR capability I'm trying to provide using Tesseract is 
just a part of a much larger app.  LiveCode allows me to build an app on my 
Mac to be deployed on Mac, Windows & Linux.  In each case the only code I 
need for each target deployment is a command line or two that runs 
Tesseract with a given set of source files that my app has 
extracted/created elsewhere. In order to make installation easy I include a 
portable version of Tesseract amongst the resources for my app.

As I'm not a C etc. coder (I last wrote serious C several decades ago!) I'm 
not able to judge which error/warning messages are significant or figure 
out how to fix them.  I was hoping to follow a recipe that would reliably 
build a portable Tesseract for the Mac and Windows.  I'm just trying 
different combinations of sub-builds until I find one that works, which is 
why I ended up with a combination of older versions of the dependencies. So 
I'm not a good person to ask to build this and report errors etc!

Best regards

Peter

On Sunday, April 23, 2017 at 7:31:23 PM UTC+1, shree wrote:
>
> Hi Peter,
> Stefan Weil has made changes to the 3.05 branch to address this issue. 
> Please give a try using the latest commit and preferably provide your 
> feedback in the issue tracker where I have added this.

-- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tesseract-ocr+unsubscr...@googlegroups.com.
To post to this group, send email to tesseract-ocr@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/66d17f6b-da1b-45d3-897e-cd566cac570d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!/bin/bash

#
# Build Script for making standalone version of Tesseract
# Wes Fowlks
# 10/01/2014
# Originally posted at:https://code.google.com/p/tesseract-ocr/issues/detail?id=1326
# Original pastebin source: http://pastebin.com/VnGLHfbr

# NOTE:
# Peter Reid, 20 April 2017
# you must set 2 environment variables to locate the runnable version of Tesseract:
#   TESSDATA_PREFIX - set to the parent folder for the tessdata folder
#   DYLD_LIBRARY_PATH - set to the path up to and including the lib folder
#
# the runnable version of Tesseract consists of the folder "tesseract" with the following content (comments in brackets):
#
#      bin (folder)
#            tesseract (the executable itself)
#      include (folder)
#            ...
#      lib (folder - pointed to by DYLD_LIBRARY_PATH)
#            ...
#      share (folder - pointed to by TESSDATA_PREFIX)
#            man (folder)
#            tessdata (folder)

BUILD_LIBJPEG=0
BUILD_ZLIB=0
BUILD_LIBPNG=0
BUILD_LEPTONICA=0
BUILD_TESSERACT=1

# Get the base directory of where the script is
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_DIR="$BASE_DIR"/build
ARCHIVE_DIR="$BASE_DIR"/archives
SRC_DIR="$BASE_DIR"/src
TESSERACT_DIR="$BASE_DIR"/tesseract

#Library Versions - unused newer versions (as of 20 April 2017):
# numerous combinations of versions have been tried but it was necessary to backtrack to earlier versions to avoid build errors
#LIBPNG_VERSION=1.6.27 -> 1.6.29

LIBJPEG_VERSION=9b
ZLIB_VERSION=1.2.11
LIBPNG_VERSION=1.6.27
LEPTONICA_VERSION=1.74.1
TESSERACT_VERSION=3.05


bail_out()
{
    echo
    echo "  Something went wrong, HALTING BUILD!" 
    echo
    exit 1
}

echo
echo
echo "==> STARTING BUILD..."
echo 

if [ ! -d "$ARCHIVE_DIR" ]; then
	mkdir "$ARCHIVE_DIR"
fi

if [ ! -d "$SRC_DIR" ]; then
	mkdir "$SRC_DIR"
fi

if [ ! -d "$BUILD_DIR" ]; then
	mkdir "$BUILD_DIR"
fi

echo "==> Base Build Directory: "
echo "    -> $BUILD_DIR"


# FIRST - Build lib Libjpeg
if [[ "$BUILD_LIBJPEG" = 1 ]]
then
        echo
        echo "==> Building Lib Jpeg"

        # Clean up old files
        rm -rf $SRC_DIR/jpeg* $BUILD_DIR/jpeg*

        if [ ! -f $ARCHIVE_DIR/jpegsrc.v$LIBJPEG_VERSION.tar.gz ]; then
                #Download the file
                curl -o $ARCHIVE_DIR/jpeg.v$LIBJPEG_VERSION.tar.gz http://www.ijg.org/files/jpegsrc.v$LIBJPEG_VERSION.tar.gz
        fi

        echo "==> Extracting archive"
        tar -xzf $ARCHIVE_DIR/jpeg.v$LIBJPEG_VERSION.tar.gz -C $SRC_DIR

        cd $SRC_DIR/jpeg-$LIBJPEG_VERSION

        echo "==> Configuring Lib Jpeg for Standalone"
        ./configure --disable-shared --prefix=$BUILD_DIR

        echo "==> Building LIBJPEG and deploying to "
        echo "    -> $BUILD_DIR"
        make install

        #Check if the build was successful
        if [ -f $BUILD_DIR/include/jpeglib.h ]; then 
                echo "==> *** LIB JPEG Build Successful ***"
        else
                echo "==> LIBJPEG build failed. Exiting."
                exit 1
        fi
else
        echo "==> Skipping LIBJPEG"
fi


# SECOND - Build lib zlib 
if [[ $BUILD_ZLIB = 1 ]]
then
        echo
        echo "==> Building ZLIB"

        # Clean up old files
        rm -rf $SRC_DIR/zlib* $BUILD_DIR/zlib*

        if [ ! -f $ARCHIVE_DIR/zlib-$ZLIB_VERSION.tar.gz ]; then
                #Download the file
                curl -o $ARCHIVE_DIR/zlib-$ZLIB_VERSION.tar.gz http://zlib.net/fossils/zlib-$ZLIB_VERSION.tar.gz
        fi

        echo "==> Extracting archive"
        tar -xzf $ARCHIVE_DIR/zlib-$ZLIB_VERSION.tar.gz -C $SRC_DIR

        cd $SRC_DIR/zlib-$ZLIB_VERSION

        echo "==> Configuring ZLIB for Standalone"
        ./configure --solo --static

        echo "==> Building Zlib and deploying to "
        echo "    -> $BUILD_DIR"
        make install prefix=$BUILD_DIR

        #Check if the build was successful
        if [ -f $BUILD_DIR/include/zlib.h ]; then 
                echo "==> *** ZLIB Build Successful ***"
        else
                echo "==> ZLIB build failed. Exiting."
                exit 1
        fi
else
        echo "==> Skipping ZLib"
fi

# THIRD - Build Lib PNG
if [[ $BUILD_LIBPNG = 1 ]]
then
      echo
        echo "==> Building Lib PNG"

        # Clean up old files
        rm -rf $SRC_DIR/libpng* $BUILD_DIR/libpng*

        if [ ! -f "$ARCHIVE_DIR/libpng-$LIBPNG_VERSION.tar.gz" ]; then
                #Download the file		ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-$LIBPNG_VERSION.tar.gz
              curl -L -o $ARCHIVE_DIR/libpng-$LIBPNG_VERSION.tar.gz ftp://ftp.simplesystems.org/pub/png/src/history/libpng16/libpng-$LIBPNG_VERSION.tar.gz
        fi

        echo "==> Extracting archive"
        tar -xzf $ARCHIVE_DIR/libpng-$LIBPNG_VERSION.tar.gz -C $SRC_DIR

        cd $SRC_DIR/libpng*

        echo "==> Copying libz header files to libpng"
        cp $BUILD_DIR/include/zlib.h .
        cp $BUILD_DIR/include/zconf.h .

        echo "==> Configuring Lib PNG for Standalone"
        ./configure --prefix=$BUILD_DIR

        echo "==> Building LIBPNG and deploying to "
        echo "    -> $BUILD_DIR"
        make check
        make install

        #Check if the build was successful
        if [ -f "$BUILD_DIR/include/libpng16/png.h" ]; then 
                echo "==> *** LIB PNG Build Successful ***"
        else
                echo "==> LIBPNG build failed. Exiting."
                exit 1
        fi

else
        echo "==> Skipping LIBPNG"
fi

# FOURTH - Build Leptonica
if [[ $BUILD_LEPTONICA = 1 ]]
then
        echo
        echo "==> Building Leptonica"

        # Clean up old files
        rm -rf $SRC_DIR/leptonica* $BUILD_DIR/leptonica*

        if [ ! -f $ARCHIVE_DIR/leptonica-$LEPTONICA_VERSION.tar.gz ]; then
                #Download the file
                curl -o $ARCHIVE_DIR/leptonica-$LEPTONICA_VERSION.tar.gz http://www.leptonica.com/source/leptonica-$LEPTONICA_VERSION.tar.gz
        fi

        echo "==> Extracting archive"
        tar -xzf $ARCHIVE_DIR/leptonica-$LEPTONICA_VERSION.tar.gz -C $SRC_DIR

        cd $SRC_DIR/leptonica-$LEPTONICA_VERSION
        
        echo "==> Configuring leptonica for standalone"
        ./make-for-local

        echo "==> Modifying environ.h"
        cat src/environ.h |sed -e 's/#define  HAVE_LIBTIFF     1/#define  HAVE_LIBTIFF     0/g' > src/environ.test.h
        mv src/environ.test.h src/environ.h

        echo "==> Copying dependencies to leptonica"
        cp -r $BUILD_DIR/include src
        cd src

        echo "==> Building LEPTONICA and deploying to "
        echo "    -> $BUILD_DIR"
        make EXTRAINCLUDES="-I./include -I./include/libpng16"

        #Check if the build was successful
        if [ -f $SRC_DIR/leptonica-$LEPTONICA_VERSION/lib/nodebug/liblept.a ]; then 
                echo "==> *** Leptonica Build Successful ***"
        else
                echo "==> LEPTONICA build failed. Exiting."
                exit 1
        fi

        echo "Copying files for Tesseract"
        cp $SRC_DIR/leptonica-$LEPTONICA_VERSION/lib/nodebug/liblept.a $BUILD_DIR/lib

        if [ ! -f $BUILD_DIR/include/leptonica ]; then
                mkdir $BUILD_DIR/include/leptonica
        fi

        cp $SRC_DIR/leptonica-$LEPTONICA_VERSION/src/*.h $BUILD_DIR/include/leptonica

else
        echo "==> Skipping Leptonica"
fi

# FINALLY - Build Tesseract
if [[ $BUILD_TESSERACT = 1 ]]
then
        echo
        echo "==> Building Tesseract..."
        
        rm -rf $SRC_DIR/tesseract*

        #Create Tesseract Build Directory
        if [ ! -d $TESSERACT_DIR ]; then
                mkdir $TESSERACT_DIR
        else
                rm -rf $TESSERACT_DIR/*
        fi

        if [ ! -f $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.tar.gz ]; then
                #Download the file
               curl -L -o $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.tar.gz https://github.com/tesseract-ocr/tesseract/archive/$TESSERACT_VERSION.zip
       fi
 
       echo "==> Extracting archive"
        tar -xzf $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.tar.gz -C $SRC_DIR
      
        cd $SRC_DIR/tesseract-$TESSERACT_VERSION

        cp -r $BUILD_DIR/include src
        cp -r $BUILD_DIR/bin src
        cp -r $BUILD_DIR/lib src
        
        echo "==> Configuring Tesseract..."
         ./autogen.sh || bail_out
	     
        export CXXFLAGS="-I$BUILD_DIR/include -I$BUILD_DIR/include/libpng16 -I$BUILD_DIR/include/leptonica -lpng -ljpeg -lz"
        export CPPFLAGS="-I$BUILD_DIR/include -I$BUILD_DIR/include/libpng16 -I$BUILD_DIR/include/leptonica -lpng -ljpeg -lz"
        export LDFLAGS="-L$BUILD_DIR/lib"
        export LIBLEPT_HEADERSDIR=$BUILD_DIR/include/leptonica
        
        ./configure --prefix=$TESSERACT_DIR --with-extra-libraries=$BUILD_DIR/lib || bail_out

        echo "==> ...Configuration done"
        echo

        echo "==> start Building Tesseract..."
        make install

        ls $TESSERACT_DIR/bin

        if [ -x $TESSERACT_DIR/bin/tesseract ]; then
                echo "Tesseract Build Successful"
        else
                echo "Tesseract build failed. Exiting."
                exit 1
        fi

        echo "==> Checking the language files"
        if [ ! -f $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.eng.tar.gz ]; then
                #Download the file
                curl -L -o $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.eng.tar.gz https://sourceforge.net/projects/tesseract-ocr-alt/files/tesseract-ocr-$TESSERACT_VERSION.eng.tar.gz
        fi

        echo "==> Checking OSD (Optical Script Detection) models"
        if [ ! -f $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.osd.tar.gz ]; then
                #Download the file
                curl -L -o $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.osd.tar.gz https://sourceforge.net/projects/tesseract-ocr-alt/files/tesseract-ocr-$TESSERACT_VERSION.osd.tar.gz
        fi

        echo "==> Installing Languages and OSD"
        tar -xzf $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.eng.tar.gz -C $TESSERACT_DIR/bin
        tar -xzf $ARCHIVE_DIR/tesseract-$TESSERACT_VERSION.osd.tar.gz -C $TESSERACT_DIR/bin

        cd $TESSERACT_DIR/bin
            
        export TESSDATA_PREFIX=$TESSERACT_DIR/share
        export DYLD_LIBRARY_PATH=$TESSERACT_DIR/lib

        echo "==> Tesseract is now built and can be found at: $TESSERACT_DIR"

else
        echo "==> Skipping Tesseract"
fi

Reply via email to