I've done some further searching and found several versions of shell
scripts that are supposed to generate a standalone version of Tesseract.
However, they all fail at the last part of the process, namely building
Tesseract itself! The script builds the libraries for zlib (v1.2.8),
libpng (v1.6.13), libjpeg (9b) and leptonica (v1.73), but fails with the
following error:
checking for leptonica... yes
checking for pixCreate in -llept... no
configure: error: leptonica library missing
I can't find a way to correct this! Here's the config details that lead to
this error:
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
[Note: I added the CXXFLAGS as well as the CPPFLAGS as I wasn't sure which
was needed]
I have attached the latest version of the shell script I'm using so you can
see the context.
Can anyone fix my script or tell me another way of generating a standalone
version of Tesseract for the Mac?
Thanks
On Thursday, March 24, 2016 at 10:49:03 AM UTC, Peter Reid wrote:
>
> I have a standalone version of tesseract-ocr for Windows that can be run
> from a folder located anywhere in the Windows filing system without having
> to do an installation. For the Mac the user has to install
> HomeBrew/MacPort first and then tesseract-ocr afterwards. This fixes
> tesseract-ocr to particular parts of the OS X filing system, preventing it
> from being relocated and used elsewhere on the Mac.
>
> I'm looking for a standalone/self-contained version of tesseract-ocr for
> the Mac that can be located anywhere and can be run without requiring
> installations. Please can someone point to such a version of tesseract-ocr
> or give instructions on how I can build one of these!
>
> Thanks
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/e6dbc1e0-1314-47e9-b76c-627db8b6afc4%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
#
BUILD_ZLIB=0
BUILD_LIBJPEG=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
ZLIB_VERSION=1.2.8
LIBPNG_VERSION=1.6.13
LIBJPEG_VERSION=9b
LEPTONICA_VERSION=1.73
TESSERACT_VERSION=3.04.01
TESSDATA_VERSION=3.04.00
# Variables and functions for coloring output
black=
red=
green=
yellow=
blue=
magenta=
cyan=
white=
bold='\033[1m'
nobold='\033[0m'
function Reset {
tput sgr0 # Reset text attributes to normal
#+ without clearing screen.
}
function cecho (){ # Color-echo. Argument $1 = message, Argument $2 = color
local default_msg="No message passed."
# Doesn't really need to be a local variable.
message=${1:-$default_msg} # Defaults to default message.
color=${2:-$black} # Defaults to black, if not specified.
echo -e -n "$color"
echo "$message"
Reset # Reset to normal.
return
}
function cbecho(){
echo -e -n "$bold"
cecho "$1" "$2"
echo -e "$nobold"
return
}
# Functions usefull throughtout the script
function setupDirs() {
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
}
function downloadSrc(){
if [[ ! -f "$ARCHIVE_DIR/$1" ]]; then
cecho "Downloading $1" $white
curl -L -o $ARCHIVE_DIR/$1 $2
fi
if [[ ! -f "$ARCHIVE_DIR/$1" ]]; then
cbecho "Download of $1 failed. Exiting!" $red
exit 1
fi
}
function extractSrc(){
cecho "Extracting archive" $white
tar -xzf "$ARCHIVE_DIR/$1" -C $SRC_DIR
}
function getSrc(){
downloadSrc $1 $2
extractSrc $1
}
function checkBuild(){
if [[ -f $1 ]]; then
cbecho "$2 Build Successful" $green
else
cbecho "$2 build failed. Exiting." $red
exit 1
fi
}
function cleanUp(){
rm -rf $SRC_DIR/$1 $BUIĆ’D_DIR/$1
}
cbecho "Base Build Directory: $BUILD_DIR" $white
# First check to see if zlib
if [[ $BUILD_ZLIB = 1 ]]
then
cbecho "Building ZLIB" $white
setupDirs
# Clean up old files
cleanUp "zlib*"
getSrc "zlib-$ZLIB_VERSION.tar.gz" "http://zlib.net/fossils/zlib-$ZLIB_VERSION.tar.gz"
cd "$SRC_DIR/zlib-$ZLIB_VERSION"
cecho "Configuring ZLIB for Standalone" $white
./configure --solo --static
cecho "Building Zlib and deploying to $BUILD_DIR" $white
make install prefix=$BUILD_DIR
checkBuild "$BUILD_DIR/include/zlib.h" "ZLIB"
else
cecho "Skipping ZLib" $blue
fi
# Build Libjpeg
if [[ $BUILD_LIBJPEG = 1 ]]
then
cbecho "Building Lib Jpeg" $white
setupDirs
cleanUp "jpeg*"
getSrc "jpegsrc.v$LIBJPEG_VERSION.tar.gz" "http://www.ijg.org/files/jpegsrc.v$LIBJPEG_VERSION.tar.gz"
cd "$SRC_DIR/jpeg-$LIBJPEG_VERSION"
cecho "Configuring Lib Jpeg for Standalone" $white
./configure --disable-shared --prefix=$BUILD_DIR
cecho "Building LIBJPEG and deploying to $BUILD_DIR" $white
make install
checkBuild "$BUILD_DIR/include/jpeglib.h" "LIB JPEG"
else
cecho "Skipping LIBJPEG" $blue
fi
# Build Lib PNG
if [[ $BUILD_LIBPNG = 1 ]]
then
cbecho "Building Lib PNG" $white
setupDirs
cleanUp "libpng*"
getSrc "libpng-$LIBPNG_VERSION.tar.gz" "https://sourceforge.net/projects/libpng/files/libpng16/older-releases/$LIBPNG_VERSION/libpng-$LIBPNG_VERSION.tar.xz"
cd "$SRC_DIR/libpng-$LIBPNG_VERSION"
cecho "Copying libz header files to libpng" $white
cp $BUILD_DIR/include/zlib.h .
cp $BUILD_DIR/include/zconf.h .
cecho "Configuring Lib PNG for Standalone" $white
./configure --prefix=$BUILD_DIR
cecho "Building LIBPNG and deploying to $BUILD_DIR" $white
make check
make install
checkBuild "$BUILD_DIR/include/libpng16/png.h" "LIB PNG"
else
cecho "Skipping LIBPNG" $blue
fi
# Build Leptonica
if [[ $BUILD_LEPTONICA = 1 ]]
then
cbecho "Building Leptonica" $white
setupDirs
# Clean up old files
cleanUp "leptonica*"
getSrc "leptonica-$LEPTONICA_VERSION.tar.gz" "http://www.leptonica.com/source/leptonica-$LEPTONICA_VERSION.tar.gz"
cd "$SRC_DIR/leptonica-$LEPTONICA_VERSION"
cecho "Configuring leptonica for standalone" $white
./make-for-local
cecho "Modifying environ.h" $white
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
cecho "Copying dependencies to leptonica" $white
cp -r $BUILD_DIR/include src
cd src
cecho "Building LEPTONICA and deploying to $BUILD_DIR" $white
make EXTRAINCLUDES="-I./include -I./include/libpng16"
checkBuild "$SRC_DIR/leptonica-$LEPTONICA_VERSION/lib/nodebug/liblept.a" "Leptonica"
cecho "Copying files for Tesseract" $white
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
cecho "Skipping Leptonica" $blue
fi
# Build Tesseract
if [[ $BUILD_TESSERACT = 1 ]]
then
cbecho "Building Tesseract" $white
cleanUp "tesseract*"
#Create Tesseract Build Directory
if [[ ! -d "$TESSERACT_DIR" ]]; then
mkdir $TESSERACT_DIR
else
rm -rf $TESSERACT_DIR/*
fi
getSrc "tesseract-ocr-$TESSERACT_VERSION.tar.gz" "https://github.com/tesseract-ocr/tesseract/archive/$TESSERACT_VERSION.tar.gz"
cd "$SRC_DIR/tesseract-$TESSERACT_VERSION"
cp -r $BUILD_DIR/include src
cp -r $BUILD_DIR/bin src
cp -r $BUILD_DIR/lib src
cecho "Configuring Tesseract" $white
#./autogen.sh
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
cecho "Configuration done, now Building" $white
make install
checkBuild "$TESSERACT_DIR/bin/tesseract" "Tesseract"
cbecho "Checking the language files" $white
downloadSrc "tesseract-ocr-$TESSDATA_VERSION.eng.tar.gz" "https://github.com/tesseract-ocr/tessdata/archive/$TESSDATA_VERSION.tar.gz"
cecho "Installing Languages and OSD" $white
tar -xzf $ARCHIVE_DIR/tesseract-ocr-3.02.eng.tar.gz -C $TESSERACT_DIR/bin
cd $TESSERACT_DIR/bin
cbecho "Tesseract is now built and can be found at: $BUILD_DIR" $green
else
cecho "Skipping Tesseract" $blue
fi